From 8c752ec86156ebfa78f91ee17fab896215bc9322 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 28 Oct 2004 11:57:20 +0000 Subject: 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) --- source4/lib/socket/socket.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source4') 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); } -- cgit