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 <[email protected]>