Closed thomasjfox closed 3 years ago
/usr/include/asm-generic/errno.h:#define EWOULDBLOCK EAGAIN /* Operation would block */
Please review https://github.com/varlink/libvarlink/pull/20
..."and does not require these constants to have the same value, so a portable application should check for both possibilities." ;)
We can either choose to ignore this fact or just change every
case EAGAIN:
xyz
to
case EAGAIN:
case EWOULDBLOCK:
xyz
As you mentioned in #17, libvarlink is tested on Linux only at the moment.
..."and does not require these constants to have the same value, so a portable application should check for both possibilities." ;)
Hmm.. epoll
is Linux only anyway.. right?
The non-blocking I/O socket code in varlink_stream_read() / varlink_stream_flush() handles EAGAIN already. It should be an easy thing to also handle EWOULDBLOCK:
From the write() man page: EAGAIN or EWOULDBLOCK
The file descriptor fd refers to a socket and has been marked non-blocking (O_NONBLOCK), and the write would block. POSIX.1-2001 allows either error to be returned for this case, and does not require these constants to have the same value, so a portable application should check for both possibilities.
Looking at the code again today, support for EINTR should also be added to varlink_stream_read() and varlink_stream_flush(). Otherwise the code errors out during normal signal delivery.