X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=liblttng-ust-comm%2Flttng-ust-comm.c;h=751ad2e3cf2add1ffd805c9ca4df802034e793b1;hb=7b1b46edbf61219313ba17e5a97ab0925cd60f16;hp=a31786ac52000994feec90a754b5f9ba9701c16c;hpb=6f0f3216eb57ce0eda0f0f1195d9f7181bac7d83;p=lttng-ust.git diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c index a31786ac..751ad2e3 100644 --- a/liblttng-ust-comm/lttng-ust-comm.c +++ b/liblttng-ust-comm/lttng-ust-comm.c @@ -265,7 +265,8 @@ ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len) { struct msghdr msg; struct iovec iov[1]; - ssize_t ret; + ssize_t ret = -1; + size_t len_last; memset(&msg, 0, sizeof(msg)); @@ -275,8 +276,14 @@ ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len) msg.msg_iovlen = 1; 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) { int shutret; @@ -290,7 +297,10 @@ ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len) shutret = shutdown(sock, SHUT_RDWR); if (shutret) ERR("Socket shutdown error"); + } else if (ret > 0) { + ret = len; } + /* ret = 0 means an orderly shutdown. */ return ret; }