Closed fredrikwidlund closed 3 weeks ago
I expect all connections to succeed but there seems to be a race and the number of successful connections vary between 1 and 4. I use a a standard accept() syscall just to simplify the test case, but regardless a cqe is not always generated when there are connections still waiting to be accepted.
I then figure I might mimic epoll edge trigged semantics instead, and repeat accept() in nonblocking mode until EAGAIN.
Right, there is no guarantee for 1:1 match b/w poll completions and accepts pending
The test unexpectedly hangs waiting for connections. Even though the socket is in nonblocking mode it does not return with EAGAIN when there are no connections waiting to be accepted.
I guess that's just another place we didn't care about O_NONBLOCK
.
Even though not particularly a solution to the API problem, but to narrow down the problem I'd ask whether something like a draft pseudo-code below works for you?
while (1) {
add_poll_req();
io_uring_submit_wait();
cqe = get_cqe();
// error handling
while (accept(O_NONBLOCK) == SUCCESS) {}
}
I would like to avoid using regular syscalls if possible. Being able to submit requests to uring flagged as "non blocking", or "complete immediately" would work, although honouring O_NONBLOCK is perhaps more stringent?
I am trying make poll semantics work before accept() on a tcp socket.
Try 1
I then connect a few clients as such...
I expect all connections to succeed but there seems to be a race and the number of successful connections vary between 1 and 4. I use a a standard accept() syscall just to simplify the test case, but regardless a cqe is not always generated when there are connections still waiting to be accepted.
I then figure I might mimic epoll edge trigged semantics instead, and repeat accept() in nonblocking mode until EAGAIN.
Try 2
The test unexpectedly hangs waiting for connections. Even though the socket is in nonblocking mode it does not return with EAGAIN when there are no connections waiting to be accepted.
How is the poll interface supposed to used in this case? Is this behaviour expected?
Linux arch 5.18.1-1-aarch64-ARCH #1 SMP PREEMPT Wed Jun 1 19:34:45 MDT 2022 aarch64 GNU/Linux