summaryrefslogtreecommitdiff
path: root/source4/lib/socket
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-28 11:57:20 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:04:53 -0500
commit8c752ec86156ebfa78f91ee17fab896215bc9322 (patch)
treedcdf03c0d34376a5403072569b876c3eb8e25508 /source4/lib/socket
parent4a25682214d15ff79ffc31665333873eab84a89c (diff)
downloadsamba-8c752ec86156ebfa78f91ee17fab896215bc9322.tar.gz
samba-8c752ec86156ebfa78f91ee17fab896215bc9322.tar.bz2
samba-8c752ec86156ebfa78f91ee17fab896215bc9322.zip
r3318: generate random STATUS_MORE_ENTRIES errors (1 in 10 packets) as well
as randomly short recv/send when socket:testnonblock is enabled (This used to be commit 718175a265d34bfdbcbf0cc6b55dbf6b389f3194)
Diffstat (limited to 'source4/lib/socket')
-rw-r--r--source4/lib/socket/socket.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c
index 22b40e076c..9bdd57d200 100644
--- a/source4/lib/socket/socket.c
+++ b/source4/lib/socket/socket.c
@@ -158,7 +158,11 @@ NTSTATUS socket_recv(struct socket_context *sock, void *buf,
}
if ((sock->flags & SOCKET_FLAG_TESTNONBLOCK) && wantlen > 1) {
- return sock->ops->recv(sock, buf, 1+(random() % (wantlen-1)), nread, flags);
+ if (random() % 10 == 0) {
+ *nread = 0;
+ return STATUS_MORE_ENTRIES;
+ }
+ return sock->ops->recv(sock, buf, 1+(random() % wantlen), nread, flags);
}
return sock->ops->recv(sock, buf, wantlen, nread, flags);
@@ -182,7 +186,11 @@ NTSTATUS socket_send(struct socket_context *sock,
if ((sock->flags & SOCKET_FLAG_TESTNONBLOCK) && blob->length > 1) {
DATA_BLOB blob2 = *blob;
- blob2.length = 1+(random() % (blob2.length-1));
+ if (random() % 10 == 0) {
+ *sendlen = 0;
+ return STATUS_MORE_ENTRIES;
+ }
+ blob2.length = 1+(random() % blob2.length);
return sock->ops->send(sock, &blob2, sendlen, flags);
}