1
0
mirror of git://sigrok.org/libserialport synced 2023-08-10 21:13:24 +03:00

unix: Fix handling of EAGAIN in sp_nonblocking_write().

This commit is contained in:
Martin Ling 2019-12-28 17:53:11 +01:00 committed by Uwe Hermann
parent 81243567bc
commit 55ab7e0b6b

View File

@ -952,10 +952,15 @@ SP_API enum sp_return sp_nonblocking_write(struct sp_port *port,
/* Returns the number of bytes written, or -1 upon failure. */
ssize_t written = write(port->fd, buf, count);
if (written < 0)
RETURN_FAIL("write() failed");
else
if (written < 0) {
if (errno == EAGAIN)
// Buffer is full, no bytes written.
RETURN_INT(0);
else
RETURN_FAIL("write() failed");
} else {
RETURN_INT(written);
}
#endif
}