On Wed, Jun 26, 2019 at 09:33:04PM -0500, Eric Blake wrote:
Another thing I just noticed: nbd_poll returns 0 both for timeout and for when it notified the state machine about POLLIN or POLLOUT making progress. We probably want to switch it to return 0 on timeout and 1 when it made progress, so that a user can detect timeout (all our internal callers pass -1 for the timeout parameter, and thus can't time out, but external callers may care).
Agreed. And another thing you said on IRC:
04:26 < eblake> urgh - libnbd is prone to die from SIGPIPE, but as a library, I don't know if we can ignore it 04:26 < eblake> should we be using pthread_sigmask and blocking SIGPIPE around our reads, and restoring it to the calling application's default the rest of the time? 04:28 < eblake> ooh - maybe we can rely on MSG_NOSIGNAL :) 04:28 < eblake> that's a lot cleaner, even if it is Linux-specific
MSG_NOSIGNAL is also available on FreeBSD and seems to make a lot of sense here, given that as you say changing the signal handler isn't a good idea from a library. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW