Skip to content

Commit

Permalink
dtprobed: handle signals hitting dtprobed better
Browse files Browse the repository at this point in the history
dtprobed is long-running and thus might get hit by signals at almost any
time.  These will cause long-running operations to return -EINTR, which
needs handling.  We were handling -EINTR when a fuse_session_receive_buf()
happened, but dtprobed spends almost all its time blocked on poll() and that
isn't handling -EINTR at all.  This came to light when tests were written
that intentionally hit dtprobed with signals: fix it by checking the poll()
for EINTR too.  (Done in two places because the core FUSE loop is duplicated
for FUSE 2 and 3.)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
nickalcock authored and kvanhees committed Feb 22, 2024
1 parent bdef79a commit 68ef5a7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dtprobed/dtprobed.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,11 @@ loop(void)
fds[0].events = POLLIN;

while (!fuse_session_exited(cuse_session)) {
if ((ret = poll(fds, 1, -1)) < 0)
if (poll(fds, 1, -1) < 0) {
if (errno == EINTR)
continue;
break;
}

if (fds[0].revents != 0) {
if ((ret = fuse_session_receive_buf(cuse_session,
Expand Down Expand Up @@ -822,8 +825,11 @@ loop(void)
struct fuse_buf fbuf = { .mem = buf, .size = bufsize };
struct fuse_chan *tmpch = cuse_chan;

if ((ret = poll(fds, 1, -1)) < 0)
if (poll(fds, 1, -1) < 0) {
if (errno == EINTR)
continue;
break;
}

if (fds[0].revents != 0) {
if ((ret = fuse_session_receive_buf(cuse_session,
Expand Down

0 comments on commit 68ef5a7

Please sign in to comment.