diff options
author | Philipp Maier <pmaier@sysmocom.de> | 2023-04-20 14:28:28 +0200 |
---|---|---|
committer | Philipp Maier <pmaier@sysmocom.de> | 2023-04-20 14:38:17 +0200 |
commit | 9f55c47e7bf168b59381cffd817990e3e412c83d (patch) | |
tree | 9f637c10287363fb3de7574c2be6477687bdbe32 | |
parent | 28c437675fc4c1ea3b37c8a9999f2376ed41b4fe (diff) |
proto_clnt: close osmo-e1d control socket on connection loss
When osmo-e1d is terminated the socket file descriptor on the client
side will get permanent POLLHUP events. This means that the registered
callback gets called with flags OSMO_FD_READ but the received data will
be of length zero. We must detect this situations and close the file
descriptor on connection loss. Otherwise we would get called over and
over again in an endless loop, resulting in 100% CPU usage.
Related: OS#5983
Change-Id: I3e1a29a9701a9432f58ef7cfedc32c916203017a
-rw-r--r-- | src/proto_clnt.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/proto_clnt.c b/src/proto_clnt.c index c703432..5b9a467 100644 --- a/src/proto_clnt.c +++ b/src/proto_clnt.c @@ -88,8 +88,12 @@ _e1dp_client_read(struct osmo_fd *ofd, unsigned int flags) struct osmo_e1dp_msg_hdr *hdr; msgb = osmo_e1dp_recv(ofd, NULL); - if (!msgb) + if (!msgb) { + LOGP(DE1D, LOGL_ERROR, "Lost connection with osmo-e1d control socket.\n"); + close(ofd->fd); + ofd->fd = 0; goto err; + } hdr = msgb_l1(msgb); if ((hdr->type & E1DP_TYPE_MSK) != E1DP_EVT_TYPE) |