Backport: Fix: relayd streams can be leaked on connection error
[lttng-tools.git] / src / common / sessiond-comm / inet.c
index ed7f5dc165e1b3961a2f53ef3107a0f54db85472..f70fc93a08dfacaba934c1d1fd5cb62b6374503b 100644 (file)
@@ -390,18 +390,22 @@ ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf,
                len_last = iov[0].iov_len;
                ret = recvmsg(sock->fd, &msg, flags);
                if (ret > 0) {
+                       if (flags & MSG_DONTWAIT) {
+                               goto end;
+                       }
                        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 inet");
        } else if (ret > 0) {
                ret = len;
        }
        /* Else ret = 0 meaning an orderly shutdown. */
-
+end:
        return ret;
 }
 
This page took 0.026183 seconds and 5 git commands to generate.