Add code to test write_data_iov a bit
authorVolker Lendecke <vl@samba.org>
Mon, 22 Dec 2008 21:42:44 +0000 (22:42 +0100)
committerKarolin Seeger <kseeger@samba.org>
Fri, 2 Jan 2009 11:44:26 +0000 (12:44 +0100)
(cherry picked from commit 8c7552790934397c1bbb7e93eb64716a5fed31fa)

source/lib/system.c

index 5b06d3c7600e943ab5dd33f66a26f4d0f37bb1ae..48ecf903d94d65462b2b7d1587a007b64c421931 100644 (file)
@@ -149,6 +149,17 @@ ssize_t sys_writev(int fd, const struct iovec *iov, int iovcnt)
 {
        ssize_t ret;
 
+#if 0
+       /* Try to confuse write_data_iov a bit */
+       if ((random() % 5) == 0) {
+               return sys_write(fd, iov[0].iov_base, iov[0].iov_len);
+       }
+       if (iov[0].iov_len > 1) {
+               return sys_write(fd, iov[0].iov_base,
+                                (random() % (iov[0].iov_len-1)) + 1);
+       }
+#endif
+
        do {
                ret = writev(fd, iov, iovcnt);
        } while (ret == -1 && errno == EINTR);