[MERGED] libosmo-netif[master]: stream: Avoid re-creating and leaking socket when unneeded

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
Sat Nov 18 10:18:23 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: stream: Avoid re-creating and leaking socket when unneeded
......................................................................


stream: Avoid re-creating and leaking socket when unneeded

In previous implementation, if no reconfiguring is needed, a new socket
would be created without closing the old one, leaking the previous
socket. Instead, if we don't need reconfiguring, we return 0 as no
operation is required.

Change-Id: I6c1a7fff63e44840fb5e2bc7ace5e9a61e304987
---
M src/stream.c
1 file changed, 6 insertions(+), 2 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/stream.c b/src/stream.c
index 71c9b17..d9c3f62 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -735,9 +735,13 @@
 {
 	int ret;
 
-	/* we are reconfiguring this socket, close existing first. */
-	if ((link->flags & OSMO_STREAM_SRV_F_RECONF) && link->ofd.fd >= 0)
+	if (link->ofd.fd >= 0) {
+		/* No reconfigure needed for existing socket, we are fine */
+		if (!(link->flags & OSMO_STREAM_SRV_F_RECONF))
+			return 0;
+		/* we are reconfiguring this socket, close existing first. */
 		osmo_stream_srv_link_close(link);
+	}
 
 	link->flags &= ~OSMO_STREAM_SRV_F_RECONF;
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6c1a7fff63e44840fb5e2bc7ace5e9a61e304987
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list