svn commit: samba r17168 - in branches/SAMBA_4_0/source/lib: socket
tls
abartlet at samba.org
abartlet at samba.org
Fri Jul 21 01:34:57 GMT 2006
Author: abartlet
Date: 2006-07-21 01:34:56 +0000 (Fri, 21 Jul 2006)
New Revision: 17168
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17168
Log:
Now that TLS (and soon SASL) is below the socket layer, we need to
make the testnonblock skip some things. The socket *under* the tls
socket is still tested.
Andrew Bartlett
Modified:
branches/SAMBA_4_0/source/lib/socket/socket.c
branches/SAMBA_4_0/source/lib/socket/socket.h
branches/SAMBA_4_0/source/lib/tls/config.mk
branches/SAMBA_4_0/source/lib/tls/tls.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/socket/socket.c
===================================================================
--- branches/SAMBA_4_0/source/lib/socket/socket.c 2006-07-21 00:56:48 UTC (rev 17167)
+++ branches/SAMBA_4_0/source/lib/socket/socket.c 2006-07-21 01:34:56 UTC (rev 17168)
@@ -66,6 +66,7 @@
/* by enabling "testnonblock" mode, all socket receive and
send calls on non-blocking sockets will randomly recv/send
less data than requested */
+
if (!(flags & SOCKET_FLAG_BLOCK) &&
type == SOCKET_TYPE_STREAM &&
lp_parm_bool(-1, "socket", "testnonblock", False)) {
@@ -185,14 +186,21 @@
return NT_STATUS_NOT_IMPLEMENTED;
}
- if ((sock->flags & SOCKET_FLAG_TESTNONBLOCK) && wantlen > 1) {
- if (random() % 10 == 0) {
- *nread = 0;
- return STATUS_MORE_ENTRIES;
+ if ((sock->flags & SOCKET_FLAG_TESTNONBLOCK)
+ && wantlen > 1) {
+
+ /* The returning of 0 and MORE_ENTRIES is incompatible
+ with TLS and SASL sockets, as there is not a
+ constant event source to re-trigger the reads */
+
+ if (!(sock->flags & SOCKET_FLAG_FAKE)) {
+ if (random() % 10 == 0) {
+ *nread = 0;
+ return STATUS_MORE_ENTRIES;
+ }
}
return sock->ops->fn_recv(sock, buf, 1+(random() % wantlen), nread);
}
-
return sock->ops->fn_recv(sock, buf, wantlen, nread);
}
@@ -229,17 +237,21 @@
if (!sock->ops->fn_send) {
return NT_STATUS_NOT_IMPLEMENTED;
}
-
- if ((sock->flags & SOCKET_FLAG_TESTNONBLOCK) && blob->length > 1) {
- DATA_BLOB blob2 = *blob;
+
+ if ((sock->flags & SOCKET_FLAG_TESTNONBLOCK)
+ && blob->length > 1) {
if (random() % 10 == 0) {
*sendlen = 0;
return STATUS_MORE_ENTRIES;
}
- blob2.length = 1+(random() % blob2.length);
- return sock->ops->fn_send(sock, &blob2, sendlen);
+ /* The variable size sends are incompatilbe with TLS and SASL
+ * sockets, which require re-sends to be consistant */
+ if (!(sock->flags & SOCKET_FLAG_FAKE)) {
+ DATA_BLOB blob2 = *blob;
+ blob2.length = 1+(random() % blob2.length);
+ return sock->ops->fn_send(sock, &blob2, sendlen);
+ }
}
-
return sock->ops->fn_send(sock, blob, sendlen);
}
Modified: branches/SAMBA_4_0/source/lib/socket/socket.h
===================================================================
--- branches/SAMBA_4_0/source/lib/socket/socket.h 2006-07-21 00:56:48 UTC (rev 17167)
+++ branches/SAMBA_4_0/source/lib/socket/socket.h 2006-07-21 01:34:56 UTC (rev 17168)
@@ -102,6 +102,7 @@
#define SOCKET_FLAG_BLOCK 0x00000001
#define SOCKET_FLAG_PEEK 0x00000002
#define SOCKET_FLAG_TESTNONBLOCK 0x00000004
+#define SOCKET_FLAG_FAKE 0x00000008 /* This is an implementation not directly on top of a real socket */
struct socket_context {
enum socket_type type;
Modified: branches/SAMBA_4_0/source/lib/tls/config.mk
===================================================================
--- branches/SAMBA_4_0/source/lib/tls/config.mk 2006-07-21 00:56:48 UTC (rev 17167)
+++ branches/SAMBA_4_0/source/lib/tls/config.mk 2006-07-21 01:34:56 UTC (rev 17168)
@@ -5,7 +5,7 @@
tls.o \
tlscert.o
PUBLIC_DEPENDENCIES = \
- LIBTALLOC GNUTLS LIBSAMBA-CONFIG
+ LIBTALLOC GNUTLS LIBSAMBA-CONFIG samba-socket
#
# End SUBSYSTEM LIBTLS
################################################
Modified: branches/SAMBA_4_0/source/lib/tls/tls.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tls/tls.c 2006-07-21 00:56:48 UTC (rev 17167)
+++ branches/SAMBA_4_0/source/lib/tls/tls.c 2006-07-21 01:34:56 UTC (rev 17168)
@@ -443,7 +443,8 @@
NTSTATUS nt_status;
nt_status = socket_create_with_ops(socket, &tls_socket_ops, &new_sock,
- SOCKET_TYPE_STREAM, 0);
+ SOCKET_TYPE_STREAM,
+ socket->flags | SOCKET_FLAG_FAKE);
if (!NT_STATUS_IS_OK(nt_status)) {
return NULL;
}
@@ -522,7 +523,8 @@
NTSTATUS nt_status;
nt_status = socket_create_with_ops(socket, &tls_socket_ops, &new_sock,
- SOCKET_TYPE_STREAM, 0);
+ SOCKET_TYPE_STREAM,
+ socket->flags | SOCKET_FLAG_FAKE);
if (!NT_STATUS_IS_OK(nt_status)) {
return NULL;
}
More information about the samba-cvs
mailing list