pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/30721 )
Change subject: stream: Avoid useless polling if tx_queue becomes empty ......................................................................
stream: Avoid useless polling if tx_queue becomes empty
Before this patch, the WRITE poll flag was being left ON and waited to be polled again by the kernel in order to disable it. Let's spate that extra polling cycle which only creates more polling triggers, context switches, etc.
Change-Id: I1dd2145249a7322ad95e49be588fd472f00734e1 --- M src/stream.c 1 file changed, 10 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/21/30721/1
diff --git a/src/stream.c b/src/stream.c index 1ca4e9a..503fe3c 100644 --- a/src/stream.c +++ b/src/stream.c @@ -387,7 +387,12 @@ } else if (ret < msgb_length(msg)) { LOGP(DLINP, LOGL_ERROR, "short send: %d < exp %u\n", ret, msgb_length(msg)); } + msgb_free(msg); + + if (llist_empty(&cli->tx_queue)) + osmo_fd_write_disable(&cli->ofd); + return 0; }
@@ -1351,8 +1356,11 @@
msgb_free(msg);
- if (llist_empty(&conn->tx_queue) && (conn->flags & OSMO_STREAM_SRV_F_FLUSH_DESTROY)) - osmo_stream_srv_destroy(conn); + if (llist_empty(&conn->tx_queue)) { + osmo_fd_write_disable(&conn->ofd); + if (conn->flags & OSMO_STREAM_SRV_F_FLUSH_DESTROY) + osmo_stream_srv_destroy(conn); + } }
static int osmo_stream_srv_cb(struct osmo_fd *ofd, unsigned int what)