Skip to content

Commit 636b836

Browse files
committed
aio-posix: signal-proof fdmon-io_uring
The io_uring_enter(2) syscall returns with errno=EINTR when interrupted by a signal. Retry the syscall in this case. It's essential to do this in the io_uring_submit_and_wait() case. My interpretation of the Linux v5.5 io_uring_enter(2) code is that it shouldn't affect the io_uring_submit() case, but there is no guarantee this will always be the case. Let's check for -EINTR around both APIs. Note that the liburing APIs have -errno return values. Signed-off-by: Stefan Hajnoczi <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Message-id: [email protected] Signed-off-by: Stefan Hajnoczi <[email protected]>
1 parent 8bac3ba commit 636b836

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

util/fdmon-io_uring.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ static struct io_uring_sqe *get_sqe(AioContext *ctx)
8888
}
8989

9090
/* No free sqes left, submit pending sqes first */
91-
ret = io_uring_submit(ring);
91+
do {
92+
ret = io_uring_submit(ring);
93+
} while (ret == -EINTR);
94+
9295
assert(ret > 1);
9396
sqe = io_uring_get_sqe(ring);
9497
assert(sqe);
@@ -282,7 +285,10 @@ static int fdmon_io_uring_wait(AioContext *ctx, AioHandlerList *ready_list,
282285

283286
fill_sq_ring(ctx);
284287

285-
ret = io_uring_submit_and_wait(&ctx->fdmon_io_uring, wait_nr);
288+
do {
289+
ret = io_uring_submit_and_wait(&ctx->fdmon_io_uring, wait_nr);
290+
} while (ret == -EINTR);
291+
286292
assert(ret >= 0);
287293

288294
return process_cq_ring(ctx, ready_list);

0 commit comments

Comments
 (0)