libubus: fix writev_retry() function when writing large packets
authorAlexandru Ardelean <ardeleanalex@gmail.com>
Fri, 27 Jun 2014 16:11:42 +0000 (19:11 +0300)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 3 Jul 2014 10:45:30 +0000 (12:45 +0200)
Seems this bug stayed hidden for a while, because the write/sendmsg function
can send up to ~200k in one send, so it looked at first why there was
some data mismatch.

libubus-io.c

index f38403f83b9eef1ff1259778bc7b5cb02d0fdec1..31dad279238aab44d9e5be69cf3ffb1bf40e7926 100644 (file)
@@ -111,7 +111,10 @@ static int writev_retry(int fd, struct iovec *iov, int iov_len, int sock_fd)
                        if (!iov_len)
                                return len;
                }
+               iov->iov_base += cur_len;
                iov->iov_len -= cur_len;
+               msghdr.msg_iov = iov;
+               msghdr.msg_iovlen = iov_len;
        } while (1);
 
        /* Should never reach here */