aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2022-05-09 12:59:35 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2022-05-09 12:59:48 +0200
commit90df035a8d70ea31041d861b8469f289bfeee000 (patch)
tree037a559d86b25a92ffca05d4bd3d4ce9d56dff2f
parentd20a10c58ba448e98ad5d89e4c61d67ce810fb2e (diff)
input/ipaccess: Avoid extra poll() call when e1i_ts tx queue becomes empty
Before this patch, the logic (both for delayed tx and immediate tx) always left the WRITE flag set, and relied on an extra call back from the main loop (poll()) to disable the flag until it found out there was nothing else to send. Instead, let's disable it immediatelly at the time we submit the last message in the queue. Change-Id: I0e5da5d1342f352d0e2bca9ee39c768bccb2c8d5
-rw-r--r--src/input/ipaccess.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index ca48d21..07fd814 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -477,12 +477,24 @@ static void ipaccess_close(struct e1inp_sign_link *sign_link)
}
}
+static bool e1i_ts_has_pending_tx_msgs(struct e1inp_ts *e1i_ts)
+{
+ struct e1inp_sign_link *link;
+ llist_for_each_entry(link, &e1i_ts->sign.sign_links, list) {
+ if (!llist_empty(&link->tx_list)) {
+ return true;
+ }
+ }
+ return false;
+}
+
static void timeout_ts1_write(void *data)
{
struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data;
/* trigger write of ts1, due to tx delay timer */
- ts_want_write(e1i_ts);
+ if (e1i_ts_has_pending_tx_msgs(e1i_ts))
+ ts_want_write(e1i_ts);
}
static int __handle_ts1_write(struct osmo_fd *bfd, struct e1inp_line *line)
@@ -535,9 +547,11 @@ static int __handle_ts1_write(struct osmo_fd *bfd, struct e1inp_line *line)
/* set tx delay timer for next event */
osmo_timer_setup(&e1i_ts->sign.tx_timer, timeout_ts1_write, e1i_ts);
osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
- }
-
+ } else {
out:
+ if (!e1i_ts_has_pending_tx_msgs(e1i_ts))
+ osmo_fd_write_disable(bfd);
+ }
msgb_free(msg);
return ret;
err: