svn commit: samba r12126 - in branches/SAMBA_4_0/source: ldap_server smb_server

metze at samba.org metze at samba.org
Thu Dec 8 10:23:56 GMT 2005


Author: metze
Date: 2005-12-08 10:23:56 +0000 (Thu, 08 Dec 2005)
New Revision: 12126

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=12126

Log:
get rid of the local ->terminate hacks, we do that genericly now

metze
Modified:
   branches/SAMBA_4_0/source/ldap_server/ldap_server.c
   branches/SAMBA_4_0/source/ldap_server/ldap_server.h
   branches/SAMBA_4_0/source/smb_server/smb_server.c
   branches/SAMBA_4_0/source/smb_server/smb_server.h


Changeset:
Modified: branches/SAMBA_4_0/source/ldap_server/ldap_server.c
===================================================================
--- branches/SAMBA_4_0/source/ldap_server/ldap_server.c	2005-12-08 09:13:28 UTC (rev 12125)
+++ branches/SAMBA_4_0/source/ldap_server/ldap_server.c	2005-12-08 10:23:56 UTC (rev 12126)
@@ -41,12 +41,11 @@
 static void ldapsrv_terminate_connection(struct ldapsrv_connection *conn, 
 					 const char *reason)
 {
-	/* we don't actually do the stream termination here as the
-	   recv/send functions dereference the connection after the
-	   packet processing callbacks. Instead we mark it for
-	   termination and do the real termination in the send/recv
-	   functions */
-	conn->terminate = reason;
+	if (conn->tls) {
+		talloc_free(conn->tls);
+		conn->tls = NULL;
+	}
+	stream_terminate_connection(conn->connection, reason);
 }
 
 /*
@@ -231,14 +230,6 @@
 		talloc_get_type(c->private, struct ldapsrv_connection);
 	
 	packet_recv(conn->packet);
-
-	if (conn->terminate) {
-		if (conn->tls) {
-			talloc_free(conn->tls);
-			conn->tls = NULL;
-		}
-		stream_terminate_connection(conn->connection, conn->terminate);
-	}
 }
 
 /*
@@ -264,14 +255,6 @@
 		talloc_get_type(c->private, struct ldapsrv_connection);
 	
 	packet_queue_run(conn->packet);
-
-	if (conn->terminate) {
-		if (conn->tls) {
-			talloc_free(conn->tls);
-			conn->tls = NULL;
-		}
-		stream_terminate_connection(conn->connection, conn->terminate);
-	}
 }
 
 /*
@@ -304,13 +287,13 @@
 				    c->event.fde, NULL, port != 389);
 	if (!conn->tls) {
 		ldapsrv_terminate_connection(conn, "ldapsrv_accept: tls_init_server() failed");
-		goto done;
+		return;
 	}
 
 	conn->packet = packet_init(conn);
 	if (conn->packet == NULL) {
 		ldapsrv_terminate_connection(conn, "out of memory");
-		goto done;
+		return;
 	}
 	packet_set_private(conn->packet, conn);
 	packet_set_tls(conn->packet, conn->tls);
@@ -324,35 +307,26 @@
 	/* Connections start out anonymous */
 	if (!NT_STATUS_IS_OK(auth_anonymous_session_info(conn, &conn->session_info))) {
 		ldapsrv_terminate_connection(conn, "failed to setup anonymous session info");
-		goto done;
+		return;
 	}
 
 	part = talloc(conn, struct ldapsrv_partition);
 	if (part == NULL) {
 		ldapsrv_terminate_connection(conn, "talloc failed");
-		goto done;
+		return;
 	}
 
 	part->base_dn = "*"; /* default partition */
 	part->ops = ldapsrv_get_sldb_partition_ops();
 	if (!NT_STATUS_IS_OK(part->ops->Init(part, conn))) {
 		ldapsrv_terminate_connection(conn, "default partition Init failed");
-		goto done;
+		return;
 	}
 
 	conn->default_partition = part;
 	DLIST_ADD_END(conn->partitions, part, struct ldapsrv_partition *);
 
 	irpc_add_name(c->msg_ctx, "ldap_server");
-
-done:
-	if (conn->terminate) {
-		if (conn->tls) {
-			talloc_free(conn->tls);
-			conn->tls = NULL;
-		}
-		stream_terminate_connection(conn->connection, conn->terminate);
-	}
 }
 
 static const struct stream_server_ops ldap_stream_ops = {

Modified: branches/SAMBA_4_0/source/ldap_server/ldap_server.h
===================================================================
--- branches/SAMBA_4_0/source/ldap_server/ldap_server.h	2005-12-08 09:13:28 UTC (rev 12125)
+++ branches/SAMBA_4_0/source/ldap_server/ldap_server.h	2005-12-08 10:23:56 UTC (rev 12126)
@@ -33,9 +33,6 @@
 	/* are we using gensec wrapping? */
 	BOOL enable_wrap;
 
-	/* connection should be terminated if non-null */
-	const char *terminate;
-
 	struct packet_context *packet;
 };
 

Modified: branches/SAMBA_4_0/source/smb_server/smb_server.c
===================================================================
--- branches/SAMBA_4_0/source/smb_server/smb_server.c	2005-12-08 09:13:28 UTC (rev 12125)
+++ branches/SAMBA_4_0/source/smb_server/smb_server.c	2005-12-08 10:23:56 UTC (rev 12126)
@@ -75,7 +75,7 @@
 */
 void smbsrv_terminate_connection(struct smbsrv_connection *smb_conn, const char *reason)
 {
-	smb_conn->terminate = reason;
+	stream_terminate_connection(smb_conn->connection, reason);
 }
 
 /*
@@ -83,17 +83,12 @@
 */
 static void smbsrv_recv(struct stream_connection *conn, uint16_t flags)
 {
-	struct smbsrv_connection *smb_conn = talloc_get_type(conn->private, struct smbsrv_connection);
+	struct smbsrv_connection *smb_conn = talloc_get_type(conn->private,
+							     struct smbsrv_connection);
 
 	DEBUG(10,("smbsrv_recv\n"));
 
 	packet_recv(smb_conn->packet);
-	if (smb_conn->terminate) {
-		talloc_free(conn->event.fde);
-		conn->event.fde = NULL;
-		stream_terminate_connection(smb_conn->connection, smb_conn->terminate);
-		return;
-	}
 
 	/* free up temporary memory */
 	lp_talloc_free();
@@ -109,7 +104,6 @@
 	packet_queue_run(smb_conn->packet);
 }
 
-
 /*
   handle socket recv errors
 */
@@ -131,11 +125,14 @@
 	DEBUG(5,("smbsrv_accept\n"));
 
 	smb_conn = talloc_zero(conn, struct smbsrv_connection);
-	if (!smb_conn) return;
+	if (!smb_conn) {
+		stream_terminate_connection(conn, "out of memory");
+		return;
+	}
 
 	smb_conn->packet = packet_init(smb_conn);
-	if (smb_conn->packet == NULL) {
-		stream_terminate_connection(conn, "out of memory");
+	if (!smb_conn->packet) {
+		smbsrv_terminate_connection(smb_conn, "out of memory");
 		return;
 	}
 	packet_set_private(smb_conn->packet, smb_conn);

Modified: branches/SAMBA_4_0/source/smb_server/smb_server.h
===================================================================
--- branches/SAMBA_4_0/source/smb_server/smb_server.h	2005-12-08 09:13:28 UTC (rev 12125)
+++ branches/SAMBA_4_0/source/smb_server/smb_server.h	2005-12-08 10:23:56 UTC (rev 12126)
@@ -295,9 +295,6 @@
 		uint8_t command;
 	} *trans_partial;
 
-	/* mark a connection for termination */
-	const char *terminate;
-
 	/* configuration parameters */
 	struct {
 		enum security_types security;



More information about the samba-cvs mailing list