Change in libosmo-netif[master]: Stream examples: fix server's endless loop

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/.

Max gerrit-no-reply at lists.osmocom.org
Tue Jan 29 17:21:00 UTC 2019


Max has uploaded this change for review. ( https://gerrit.osmocom.org/12724


Change subject: Stream examples: fix server's endless loop
......................................................................

Stream examples: fix server's endless loop

Stream server example had an error which resulted in infinite loop on
client disconnect. Fix this by properly handling client closing
connection to allow it to reconnect multiple times.

Change-Id: Icfc2cf7f971b9e3a4abc34cc18d8a44c811c5617
---
M examples/stream-server.c
1 file changed, 6 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/24/12724/1

diff --git a/examples/stream-server.c b/examples/stream-server.c
index cd6dc57..31487a0 100644
--- a/examples/stream-server.c
+++ b/examples/stream-server.c
@@ -56,9 +56,12 @@
 
 	bytes = osmo_stream_srv_recv(conn, msg);
 
-	if (bytes < 0) {
-		LOGPC(DSTREAMTEST, LOGL_ERROR, "cannot receive message: %s\n", strerror(-bytes));
-		return 0;
+	if (bytes <= 0) {
+		if (bytes < 0)
+			LOGPC(DSTREAMTEST, LOGL_ERROR, "cannot receive message: %s\n", strerror(-bytes));
+		else
+			LOGPC(DSTREAMTEST, LOGL_ERROR, "client closed connection\n");
+		osmo_stream_srv_destroy(conn);
 	} else
 		LOGPC(DSTREAMTEST, LOGL_NOTICE, "got %d (%d) bytes: %s\n", bytes, msg->len, msgb_hexdump(msg));
 

-- 
To view, visit https://gerrit.osmocom.org/12724
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icfc2cf7f971b9e3a4abc34cc18d8a44c811c5617
Gerrit-Change-Number: 12724
Gerrit-PatchSet: 1
Gerrit-Owner: Max <msuraev at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190129/8de6fda7/attachment.htm>


More information about the gerrit-log mailing list