X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fsessiond-comm%2Funix.c;h=a66bb750a8633567d8020ba3ac1c1d6571f62662;hb=23c2bd47c5ccd0e41e6f9e27fed5cdcfa0ed00f4;hp=0d7c95a7637638f066b28f0c2dbe14dc2bbd393d;hpb=783a3b9aa609d6805e1463655d25c7ae176c4859;p=lttng-tools.git diff --git a/src/common/sessiond-comm/unix.c b/src/common/sessiond-comm/unix.c index 0d7c95a76..a66bb750a 100644 --- a/src/common/sessiond-comm/unix.c +++ b/src/common/sessiond-comm/unix.c @@ -17,6 +17,7 @@ */ #define _GNU_SOURCE +#define _LGPL_SOURCE #include #include #include @@ -172,7 +173,7 @@ ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len) do { len_last = iov[0].iov_len; - ret = recvmsg(sock, &msg, 0); + ret = recvmsg(sock, &msg, MSG_NOSIGNAL); if (ret > 0) { iov[0].iov_base += ret; iov[0].iov_len -= ret; @@ -435,6 +436,7 @@ ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len, struct msghdr msg; struct iovec iov[1]; ssize_t ret; + size_t len_last; #ifdef __linux__ struct cmsghdr *cmptr; size_t sizeof_cred = sizeof(lttng_sock_cred); @@ -461,12 +463,21 @@ ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len, #endif /* __linux__ */ do { + len_last = iov[0].iov_len; ret = recvmsg(sock, &msg, 0); - } while (ret < 0 && errno == EINTR); + 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 fds"); goto end; + } else if (ret > 0) { + ret = len; } + /* Else ret = 0 meaning an orderly shutdown. */ #ifdef __linux__ if (msg.msg_flags & MSG_CTRUNC) {