aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2019-01-29 18:17:57 +0100
committerMax <msuraev@sysmocom.de>2019-01-29 18:20:34 +0100
commit4ce53ff10755ccb19914a7017dad2905d0339125 (patch)
treeabc27d1473cdbb0ced5329b0ad374c987efde423 /examples
parentf8767012c83a762cca7f05ebc0729c227bc303c9 (diff)
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
Diffstat (limited to 'examples')
-rw-r--r--examples/stream-server.c9
1 files changed, 6 insertions, 3 deletions
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 @@ int read_cb(struct osmo_stream_srv *conn)
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));