From fe294e811942ba512f3276c26aa7e24060e37f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Thu, 9 Mar 2023 21:53:01 +0100 Subject: [PATCH] udp: uring: wait for num_send_added.max(1), improve comments --- aquatic_udp/src/workers/socket/uring/mod.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/aquatic_udp/src/workers/socket/uring/mod.rs b/aquatic_udp/src/workers/socket/uring/mod.rs index d4c8374..779ec4e 100644 --- a/aquatic_udp/src/workers/socket/uring/mod.rs +++ b/aquatic_udp/src/workers/socket/uring/mod.rs @@ -153,8 +153,9 @@ impl SocketWorker { let recv_entry = self .recv_helper .create_entry(self.buf_ring.bgid().try_into().unwrap()); - // This timeout makes it possible to avoid busy-polling and enables - // regular updates of pending_scrape_valid_until + // This timeout enables regular updates of pending_scrape_valid_until + // and wakes the main loop to send any pending responses in the case + // of no incoming requests let pulse_timeout_entry = Timeout::new(&self.pulse_timeout as *const _) .build() .user_data(USER_DATA_PULSE_TIMEOUT); @@ -250,11 +251,11 @@ impl SocketWorker { } } - // Wait for all sendmsg entries to complete, as well as at least - // one recvmsg or timeout, in order to avoid busy-polling if there - // is no incoming data. + // Wait for all sendmsg entries to complete. If none were added, + // wait for at least one recvmsg or timeout in order to avoid + // busy-polling if there is no incoming data. ring.submitter() - .submit_and_wait(num_send_added + 1) + .submit_and_wait(num_send_added.max(1)) .unwrap(); for cqe in ring.completion() {