[PATCH] osmocom-bb[master]: VIRT-PHY: Use osmo_fd_close() introduced in libosmocore

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Jul 19 11:54:38 UTC 2017


Review at  https://gerrit.osmocom.org/3280

VIRT-PHY: Use osmo_fd_close() introduced in libosmocore

libosmocore has recently received a new function osmo_fd_close() which
can be used to replace the private fd_close() function in this code.

This requires Change-Id Icd0933eed6a24edde7cdcb378e138897ecc5332c in
libosmocore.

Change-Id: Id8a518dfb09465c2765681407e5581aee2d62d6d
---
M src/host/virt_phy/src/shared/osmo_mcast_sock.c
1 file changed, 4 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/80/3280/1

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 0521c0d..b52e005 100644
--- a/src/host/virt_phy/src/shared/osmo_mcast_sock.c
+++ b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
@@ -10,17 +10,6 @@
 #include <unistd.h>
 #include <virtphy/osmo_mcast_sock.h>
 
-/* convenience wrapper */
-static void fd_close(struct osmo_fd *ofd)
-{
-	/* multicast memberships of socket are implicitly dropped when
-	 * socket is closed */
-	osmo_fd_unregister(ofd);
-	close(ofd->fd);
-	ofd->fd = -1;
-	ofd->when = 0;
-}
-
 /* server socket is what we use for transmission. It is not subscribed
  * to a multicast group or locally bound, but it is just a normal UDP
  * socket that's connected to the remote mcast group + port */
@@ -69,7 +58,7 @@
 	rc = osmo_sock_mcast_subscribe(ofd->fd, mcast_group);
 	if (rc < 0) {
 		perror("Failed to join to mcast goup");
-		fd_close(ofd);
+		osmo_fd_close(ofd);
 		return rc;
 	}
 
@@ -96,7 +85,7 @@
 	}
 	rc = mcast_server_sock_setup(&bidir_sock->tx_ofd, tx_mcast_group, tx_mcast_port, loopback);
 	if (rc < 0) {
-		fd_close(&bidir_sock->rx_ofd);
+		osmo_fd_close(&bidir_sock->rx_ofd);
 		talloc_free(bidir_sock);
 		return NULL;
 	}
@@ -117,7 +106,7 @@
 
 void mcast_bidir_sock_close(struct mcast_bidir_sock *bidir_sock)
 {
-	fd_close(&bidir_sock->tx_ofd);
-	fd_close(&bidir_sock->rx_ofd);
+	osmo_fd_close(&bidir_sock->tx_ofd);
+	osmo_fd_close(&bidir_sock->rx_ofd);
 	talloc_free(bidir_sock);
 }

-- 
To view, visit https://gerrit.osmocom.org/3280
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id8a518dfb09465c2765681407e5581aee2d62d6d
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list