From 6637a289da9267c021497112d420ff0665507f50 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Thu, 17 Dec 2015 14:47:51 +0100 Subject: [PATCH] hnb-test: Handle closed connections correctly --- src/tests/hnb-test.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/tests/hnb-test.c b/src/tests/hnb-test.c index bfbedfc1..e5f4951e 100644 --- a/src/tests/hnb-test.c +++ b/src/tests/hnb-test.c @@ -213,9 +213,19 @@ static int hnb_read_cb(struct osmo_fd *fd) if (rc < 0) { LOGP(DMAIN, LOGL_ERROR, "Error during sctp_recvmsg()\n"); /* FIXME: clean up after disappeared HNB */ + close(fd->fd); + osmo_fd_unregister(fd); return rc; - } else + } else if (rc == 0) { + LOGP(DMAIN, LOGL_INFO, "Connection to HNB closed\n"); + close(fd->fd); + osmo_fd_unregister(fd); + fd->fd = -1; + + return -1; + } else { msgb_put(msg, rc); + } if (flags & MSG_NOTIFICATION) { LOGP(DMAIN, LOGL_DEBUG, "Ignoring SCTP notification\n");