From: Jérémie Galarneau Date: Tue, 18 Dec 2018 19:01:08 +0000 (-0500) Subject: Fix: error logged on partial recvmsg() in MSG_DONTWAIT X-Git-Tag: v2.11.0-rc2~93 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bde875091bf02f3ee9ad7b85fdbef76bbb59c317;p=lttng-tools.git Fix: error logged on partial recvmsg() in MSG_DONTWAIT The relay daemon logs a "Resource temporarily unavailable" error message when the lttcomm_recvmsg_inet_sock() is invoked and no data is left to be consumed from the lttcomm_sock. The "recvmsg" socket operation is called in a loop by the relay daemon to consume the data being received in 64k chunks. If, on one of those iterations, 0 bytes are available, recvmsg() will return an error (-1, errno = EAGAIN). This should not be logged in non-blocking mode. Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/sessiond-comm/inet.c b/src/common/sessiond-comm/inet.c index ac450dbc8..57ffbe45c 100644 --- a/src/common/sessiond-comm/inet.c +++ b/src/common/sessiond-comm/inet.c @@ -381,6 +381,15 @@ ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf, } while ((ret > 0 && ret < len_last) || (ret < 0 && errno == EINTR)); if (ret < 0) { + if (errno == EAGAIN && flags & MSG_DONTWAIT) { + /* + * EAGAIN is expected in non-blocking mode and should + * not be reported as an error. Moreover, if no data + * was read, 0 must not be returned as it would be + * interpreted as an orderly shutdown of the socket. + */ + goto end; + } PERROR("recvmsg inet"); } else if (ret > 0) { ret = len;