diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2022-12-20 15:21:00 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2022-12-20 15:23:00 +0100 |
commit | 5df412519bc2acc8eb67339957ad11a8507ceb12 (patch) | |
tree | 870908041b5dbbb6380a60f8c9d24ee493e8fe0d | |
parent | be6a895edecdf9bedca6728ce51d22368799789f (diff) |
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
-rw-r--r-- | src/stream.c | 12 |
1 files changed, 10 insertions, 2 deletions
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 @@ static int osmo_stream_cli_write(struct osmo_stream_cli *cli) } 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 @@ static void osmo_stream_srv_write(struct osmo_stream_srv *conn) 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) |