summaryrefslogtreecommitdiffstats
path: root/src/host/virt_phy
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-07-13 14:18:09 +0200
committerHarald Welte <laforge@gnumonks.org>2017-07-13 14:18:09 +0200
commit16da443e7376fcf7c88757f8ce2a342a0fd48a99 (patch)
tree0f906360fe3a2c48f934c36a1746d8f874d7a247 /src/host/virt_phy
parent0d0d2ec72437216f8cb71ffaee4700b7fbc98edb (diff)
VIRT-PHY: mcast_sock: properly clean up in error paths (close/unreg socket)
Diffstat (limited to 'src/host/virt_phy')
-rw-r--r--src/host/virt_phy/src/shared/osmo_mcast_sock.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/host/virt_phy/src/shared/osmo_mcast_sock.c b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
index 11a1aa96..3a3c77a9 100644
--- a/src/host/virt_phy/src/shared/osmo_mcast_sock.c
+++ b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
@@ -42,6 +42,7 @@ int mcast_server_sock_setup(struct osmo_fd *ofd, const char* tx_mcast_group, int
rc = setsockopt(ofd->fd, IPPROTO_IP, IP_MULTICAST_LOOP, &loopback, sizeof(loopback));
if (rc < 0) {
perror("Failed to configure multicast loopback.\n");
+ fd_close(ofd);
return rc;
}
@@ -77,6 +78,7 @@ int mcast_client_sock_setup(struct osmo_fd *ofd, const char *mcast_group, int mc
&loopback, sizeof(loopback));
if (rc < 0) {
perror("Failed to enable IP_MULTICAST_LOOP");
+ fd_close(ofd);
return rc;
}
@@ -87,6 +89,7 @@ int mcast_client_sock_setup(struct osmo_fd *ofd, const char *mcast_group, int mc
rc = setsockopt(ofd->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
if (rc < 0) {
perror("Failed to join to mcast goup");
+ fd_close(ofd);
return rc;
}
@@ -94,6 +97,7 @@ int mcast_client_sock_setup(struct osmo_fd *ofd, const char *mcast_group, int mc
* from sockets we are subscribed to via IP_ADD_MEMBERSHIP are received */
if (setsockopt(ofd->fd, IPPROTO_IP, IP_MULTICAST_ALL, &all, sizeof(all)) < 0) {
perror("Failed to modify delivery policy to explicitly joined.\n");
+ fd_close(ofd);
return rc;
}