Skip to content

Commit

Permalink
Handle interrupts in __ublksrv_ctrl_cmd
Browse files Browse the repository at this point in the history
The syscall io_uring_enter may return EINTR if it is interrupted by a
delivery of a signal. Since __ublksrv_ctrl_cmd already added an SQE, it's
easier for ublksrv to handle the error instead of the caller.

For example, if ublksrv_ctrl_start_dev() returns -EINTR, then the caller
has to either manually wait for the CQE or might call
ublksrv_ctrl_start_dev() again, resulting in an erroneous second SQE.
(Which may have no effect, but handling the interrupt seems the most
correct)
  • Loading branch information
mattysweeps committed Dec 17, 2024
1 parent 33ded74 commit 420d9e0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ublksrv_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ static int __ublksrv_ctrl_cmd(struct ublksrv_ctrl_dev *dev,
return ret;
}

ret = io_uring_wait_cqe(&dev->ring, &cqe);
do {
ret = io_uring_wait_cqe(&dev->ring, &cqe);
} while (ret == -EINTR);
if (ret < 0) {
fprintf(stderr, "wait cqe: %s\n", strerror(-ret));
return ret;
Expand Down

0 comments on commit 420d9e0

Please sign in to comment.