X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fsessiond-comm%2Funix.c;h=bbf030f67f6bc0cef88b956af83da132f548bd57;hp=2f79f3a280a123bd85a861ff039f72e5e4c6064c;hb=7c5aef6226a4752f3a4e60cd0b52c741dced395e;hpb=907b42de38da8455f22f2b4e03fbc8e75ecbd38a diff --git a/src/common/sessiond-comm/unix.c b/src/common/sessiond-comm/unix.c index 2f79f3a28..bbf030f67 100644 --- a/src/common/sessiond-comm/unix.c +++ b/src/common/sessiond-comm/unix.c @@ -157,6 +157,7 @@ ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len) struct msghdr msg; struct iovec iov[1]; ssize_t ret = -1; + size_t len_last; memset(&msg, 0, sizeof(msg)); @@ -166,11 +167,20 @@ ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len) msg.msg_iovlen = 1; do { - ret = recvmsg(sock, &msg, MSG_WAITALL); - } while (ret < 0 && errno == EINTR); + len_last = iov[0].iov_len; + ret = recvmsg(sock, &msg, 0); + if (ret > 0) { + iov[0].iov_base += ret; + iov[0].iov_len -= ret; + assert(ret <= len_last); + } + } while ((ret > 0 && ret < len_last) || (ret < 0 && errno == EINTR)); if (ret < 0) { PERROR("recvmsg"); + } else if (ret > 0) { + ret = len; } + /* Else ret = 0 meaning an orderly shutdown. */ return ret; }