Sorry for a late reply...
On Sat, Oct 23, 2021 at 11:10:08AM +0100, Richard W.M. Jones wrote:
> Fixing this in nbd_unlock_poll() avoids this issue in the
entire
> library, when we wait for command completion. This seems more useful
> that fixing it in all libnbd clients.
>
> +++ b/lib/poll.c
> @@ -57,8 +57,11 @@ nbd_unlocked_poll (struct nbd_handle *h, int timeout)
> * would allow other threads to close file descriptors which we have
> * passed to poll.
> */
> - r = poll (fds, 1, timeout);
> - debug (h, "poll end: r=%d revents=%x", r, fds[0].revents);
> + do {
> + r = poll (fds, 1, timeout);
> + debug (h, "poll end: r=%d revents=%x", r, fds[0].revents);
> + } while (r == -1 && errno == EINTR);
> +
> if (r == -1) {
> set_error (errno, "poll");
> return -1;
I think this is a perfectly reasonable solution, and better than
modifying the language bindings. I guess Eric should have the final
word here, but from my point of view ACK.
As a library, libnbd has no idea if the overall program has installed
signal handlers that may trigger EINTR, so being robust by retrying
seems the sanest approach. ACK from me as well.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization:
qemu.org |
libvirt.org