aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-02-18 13:27:49 -0700
committerJens Axboe <axboe@kernel.dk>2024-02-18 13:27:49 -0700
commit42a135ee6f781032e869e0825d20483d94c67bf4 (patch)
treeabfca779f36f59167d8ab7526e6d58d9aa2571c6
parentd951b2c273d4ce9c0d1fb3fabffb3ed092c437e3 (diff)
downloadliburing-42a135ee6f781032e869e0825d20483d94c67bf4.tar.gz
examples/proxy: don't wait batch if we have connections going away
If connections are going away, stop wait batching until they have. This prevents longer delays in processing as we're not expecting a lot of packets at that time. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--examples/proxy.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/proxy.c b/examples/proxy.c
index ac10a0dd..8ba920ba 100644
--- a/examples/proxy.c
+++ b/examples/proxy.c
@@ -1099,6 +1099,7 @@ static int event_loop(struct io_uring *ring, int fd)
{
struct __kernel_timespec active_ts, idle_ts = { .tv_sec = 1, };
struct io_uring_sqe *sqe;
+ int flags;
/*
* proxy provides a way to use either multishot receive or not, but
@@ -1125,11 +1126,12 @@ static int event_loop(struct io_uring *ring, int fd)
}
active_ts.tv_nsec = wait_usec * 1000;
+ flags = 0;
while (1) {
struct __kernel_timespec *ts = &idle_ts;
struct io_uring_cqe *cqe;
unsigned int head;
- int flags, i, to_wait;
+ int i, to_wait;
/*
* If wait_batch is set higher than 1, then we'll wait on
@@ -1148,7 +1150,7 @@ static int event_loop(struct io_uring *ring, int fd)
* always.
*/
to_wait = 1;
- if (open_conns) {
+ if (open_conns && !flags) {
ts = &active_ts;
to_wait = open_conns * wait_batch;
}