svn commit: samba r23168 - in branches: SAMBA_3_0/source/printing SAMBA_3_0/source/smbd SAMBA_3_0_26/source/printing SAMBA_3_0_26/source/smbd

vlendec at samba.org vlendec at samba.org
Sun May 27 16:34:49 GMT 2007


Author: vlendec
Date: 2007-05-27 16:34:49 +0000 (Sun, 27 May 2007)
New Revision: 23168

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

Log:
Move the lp_max_connections() into service.c.

Modified:
   branches/SAMBA_3_0/source/printing/printing.c
   branches/SAMBA_3_0/source/smbd/connection.c
   branches/SAMBA_3_0/source/smbd/negprot.c
   branches/SAMBA_3_0/source/smbd/server.c
   branches/SAMBA_3_0/source/smbd/service.c
   branches/SAMBA_3_0_26/source/printing/printing.c
   branches/SAMBA_3_0_26/source/smbd/connection.c
   branches/SAMBA_3_0_26/source/smbd/negprot.c
   branches/SAMBA_3_0_26/source/smbd/server.c
   branches/SAMBA_3_0_26/source/smbd/service.c


Changeset:
Modified: branches/SAMBA_3_0/source/printing/printing.c
===================================================================
--- branches/SAMBA_3_0/source/printing/printing.c	2007-05-27 16:22:12 UTC (rev 23167)
+++ branches/SAMBA_3_0/source/printing/printing.c	2007-05-27 16:34:49 UTC (rev 23168)
@@ -1396,7 +1396,7 @@
 		/* Child. */
 		DEBUG(5,("start_background_queue: background LPQ thread started\n"));
 
-		claim_connection( NULL, "smbd lpq backend", 0, 
+		claim_connection( NULL, "smbd lpq backend",
 			FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL);
 
 		if (!locking_init(0)) {

Modified: branches/SAMBA_3_0/source/smbd/connection.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/connection.c	2007-05-27 16:22:12 UTC (rev 23167)
+++ branches/SAMBA_3_0/source/smbd/connection.c	2007-05-27 16:34:49 UTC (rev 23168)
@@ -167,7 +167,7 @@
 ****************************************************************************/
 
 BOOL claim_connection(connection_struct *conn, const char *name,
-		      int max_connections, uint32 msg_flags)
+		      uint32 msg_flags)
 {
 	struct connections_key key;
 	struct connections_data crec;
@@ -178,24 +178,8 @@
 		return False;
 	}
 	
-	/*
-	 * Enforce the max connections parameter.
-	 */
+	DEBUG(5,("claiming %s\n",name));
 
-	if (max_connections > 0) {
-		int curr_connections;
-		
-		curr_connections = count_current_connections( lp_servicename(SNUM(conn)), True );
-
-		if (curr_connections >= max_connections) {
-			DEBUG(1,("claim_connection: Max connections (%d) exceeded for %s\n",
-				max_connections, name ));
-			return False;
-		}
-	}
-
-	DEBUG(5,("claiming %s %d\n",name,max_connections));
-
 	make_conn_key(conn, name, &kbuf, &key);
 
 	/* fill in the crec */

Modified: branches/SAMBA_3_0/source/smbd/negprot.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/negprot.c	2007-05-27 16:22:12 UTC (rev 23167)
+++ branches/SAMBA_3_0/source/smbd/negprot.c	2007-05-27 16:34:49 UTC (rev 23168)
@@ -584,7 +584,8 @@
 	   when the client connects to port 445.  Of course there is a small
 	   window where we are listening to messages   -- jerry */
 
-	claim_connection(NULL,"",0,FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL);
+	claim_connection(
+		NULL,"",FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL);
     
 	/* Check for protocols, most desirable first */
 	for (protocol = 0; supported_protocols[protocol].proto_name; protocol++) {

Modified: branches/SAMBA_3_0/source/smbd/server.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/server.c	2007-05-27 16:22:12 UTC (rev 23167)
+++ branches/SAMBA_3_0/source/smbd/server.c	2007-05-27 16:34:49 UTC (rev 23168)
@@ -1040,7 +1040,7 @@
 	/* Setup the main smbd so that we can get messages. */
 	/* don't worry about general printing messages here */
 
-	claim_connection(NULL,"",0,FLAG_MSG_GENERAL|FLAG_MSG_SMBD);
+	claim_connection(NULL,"",FLAG_MSG_GENERAL|FLAG_MSG_SMBD);
 
 	/* only start the background queue daemon if we are 
 	   running as a daemon -- bad things will happen if

Modified: branches/SAMBA_3_0/source/smbd/service.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/service.c	2007-05-27 16:22:12 UTC (rev 23167)
+++ branches/SAMBA_3_0/source/smbd/service.c	2007-05-27 16:34:49 UTC (rev 23168)
@@ -989,17 +989,31 @@
 	}
 
 /* ROOT Activities: */	
-	/* check number of connections */
-	if (!claim_connection(conn,
-			      lp_servicename(snum),
-			      lp_max_connections(snum),
-			      0)) {
-		DEBUG(1,("too many connections - rejected\n"));
+	/*
+	 * Enforce the max connections parameter.
+	 */
+
+	if ((lp_max_connections(snum) > 0)
+	    && (count_current_connections(lp_servicename(SNUM(conn)), True) >=
+		lp_max_connections(snum))) {
+
+		DEBUG(1, ("Max connections (%d) exceeded for %s\n",
+			  lp_max_connections(snum), lp_servicename(snum)));
 		conn_free(conn);
 		*status = NT_STATUS_INSUFFICIENT_RESOURCES;
 		return NULL;
 	}  
 
+	/*
+	 * Get us an entry in the connections db
+	 */
+	if (!claim_connection(conn, lp_servicename(snum), 0)) {
+		DEBUG(1, ("Could not store connections entry\n"));
+		conn_free(conn);
+		*status = NT_STATUS_INTERNAL_DB_ERROR;
+		return NULL;
+	}  
+
 	/* Preexecs are done here as they might make the dir we are to ChDir
 	 * to below */
 	/* execute any "root preexec = " line */

Modified: branches/SAMBA_3_0_26/source/printing/printing.c
===================================================================
--- branches/SAMBA_3_0_26/source/printing/printing.c	2007-05-27 16:22:12 UTC (rev 23167)
+++ branches/SAMBA_3_0_26/source/printing/printing.c	2007-05-27 16:34:49 UTC (rev 23168)
@@ -1396,7 +1396,7 @@
 		/* Child. */
 		DEBUG(5,("start_background_queue: background LPQ thread started\n"));
 
-		claim_connection( NULL, "smbd lpq backend", 0, 
+		claim_connection( NULL, "smbd lpq backend",
 			FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL);
 
 		if (!locking_init(0)) {

Modified: branches/SAMBA_3_0_26/source/smbd/connection.c
===================================================================
--- branches/SAMBA_3_0_26/source/smbd/connection.c	2007-05-27 16:22:12 UTC (rev 23167)
+++ branches/SAMBA_3_0_26/source/smbd/connection.c	2007-05-27 16:34:49 UTC (rev 23168)
@@ -139,7 +139,7 @@
 ****************************************************************************/
 
 BOOL claim_connection(connection_struct *conn, const char *name,
-		      int max_connections, uint32 msg_flags)
+		      uint32 msg_flags)
 {
 	struct connections_key key;
 	struct connections_data crec;
@@ -150,24 +150,8 @@
 		return False;
 	}
 	
-	/*
-	 * Enforce the max connections parameter.
-	 */
+	DEBUG(5,("claiming %s\n",name));
 
-	if (max_connections > 0) {
-		int curr_connections;
-		
-		curr_connections = count_current_connections( lp_servicename(SNUM(conn)), True );
-
-		if (curr_connections >= max_connections) {
-			DEBUG(1,("claim_connection: Max connections (%d) exceeded for %s\n",
-				max_connections, name ));
-			return False;
-		}
-	}
-
-	DEBUG(5,("claiming %s %d\n",name,max_connections));
-
 	make_conn_key(conn, name, &kbuf, &key);
 
 	/* fill in the crec */

Modified: branches/SAMBA_3_0_26/source/smbd/negprot.c
===================================================================
--- branches/SAMBA_3_0_26/source/smbd/negprot.c	2007-05-27 16:22:12 UTC (rev 23167)
+++ branches/SAMBA_3_0_26/source/smbd/negprot.c	2007-05-27 16:34:49 UTC (rev 23168)
@@ -580,7 +580,8 @@
 	   when the client connects to port 445.  Of course there is a small
 	   window where we are listening to messages   -- jerry */
 
-	claim_connection(NULL,"",0,FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL);
+	claim_connection(
+		NULL,"",FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL);
     
 	/* Check for protocols, most desirable first */
 	for (protocol = 0; supported_protocols[protocol].proto_name; protocol++) {

Modified: branches/SAMBA_3_0_26/source/smbd/server.c
===================================================================
--- branches/SAMBA_3_0_26/source/smbd/server.c	2007-05-27 16:22:12 UTC (rev 23167)
+++ branches/SAMBA_3_0_26/source/smbd/server.c	2007-05-27 16:34:49 UTC (rev 23168)
@@ -1088,7 +1088,7 @@
 	/* Setup the main smbd so that we can get messages. */
 	/* don't worry about general printing messages here */
 
-	claim_connection(NULL,"",0,FLAG_MSG_GENERAL|FLAG_MSG_SMBD);
+	claim_connection(NULL,"",FLAG_MSG_GENERAL|FLAG_MSG_SMBD);
 
 	/* only start the background queue daemon if we are 
 	   running as a daemon -- bad things will happen if

Modified: branches/SAMBA_3_0_26/source/smbd/service.c
===================================================================
--- branches/SAMBA_3_0_26/source/smbd/service.c	2007-05-27 16:22:12 UTC (rev 23167)
+++ branches/SAMBA_3_0_26/source/smbd/service.c	2007-05-27 16:34:49 UTC (rev 23168)
@@ -888,17 +888,31 @@
 	}
 
 /* ROOT Activities: */	
-	/* check number of connections */
-	if (!claim_connection(conn,
-			      lp_servicename(snum),
-			      lp_max_connections(snum),
-			      0)) {
-		DEBUG(1,("too many connections - rejected\n"));
+	/*
+	 * Enforce the max connections parameter.
+	 */
+
+	if ((lp_max_connections(snum) > 0)
+	    && (count_current_connections(lp_servicename(SNUM(conn)), True) >=
+		lp_max_connections(snum))) {
+
+		DEBUG(1, ("Max connections (%d) exceeded for %s\n",
+			  lp_max_connections(snum), lp_servicename(snum)));
 		conn_free(conn);
 		*status = NT_STATUS_INSUFFICIENT_RESOURCES;
 		return NULL;
 	}  
 
+	/*
+	 * Get us an entry in the connections db
+	 */
+	if (!claim_connection(conn, lp_servicename(snum), 0)) {
+		DEBUG(1, ("Could not store connections entry\n"));
+		conn_free(conn);
+		*status = NT_STATUS_INTERNAL_DB_ERROR;
+		return NULL;
+	}  
+
 	/* Preexecs are done here as they might make the dir we are to ChDir
 	 * to below */
 	/* execute any "root preexec = " line */



More information about the samba-cvs mailing list