ubusd: fix comparison of integers of different signs
[project/ubus.git] / libubus-io.c
index daa710677880c1d5933b45ab9b528116c5f320ca..228af5ca279c6d5f3d428c7ee4fe0b2670a68c1d 100644 (file)
@@ -174,9 +174,6 @@ static int recv_retry(struct ubus_context *ctx, struct iovec *iov, bool wait, in
        };
 
        while (iov->iov_len > 0) {
-               if (wait)
-                       wait_data(fd, false);
-
                if (recv_fd) {
                        msghdr.msg_control = &fd_buf;
                        msghdr.msg_controllen = sizeof(fd_buf);
@@ -192,8 +189,6 @@ static int recv_retry(struct ubus_context *ctx, struct iovec *iov, bool wait, in
 
                if (bytes < 0) {
                        bytes = 0;
-                       if (uloop_cancelling() || ctx->cancel_poll)
-                               return 0;
                        if (errno == EINTR)
                                continue;
 
@@ -212,6 +207,9 @@ static int recv_retry(struct ubus_context *ctx, struct iovec *iov, bool wait, in
                iov->iov_len -= bytes;
                iov->iov_base += bytes;
                total += bytes;
+
+               if (iov->iov_len > 0)
+                       wait_data(fd, false);
        }
 
        return total;