summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
}