r23168: Move the lp_max_connections() into service.c.
authorVolker Lendecke <vlendec@samba.org>
Sun, 27 May 2007 16:34:49 +0000 (16:34 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:22:51 +0000 (12:22 -0500)
(This used to be commit 4afe37d431b6eb475769a2057025da9aa8d1bb14)

source3/printing/printing.c
source3/smbd/connection.c
source3/smbd/negprot.c
source3/smbd/server.c
source3/smbd/service.c

index 780880cbe7e230876b7a084b3f63088fc7b5bbf9..3453598480c2db1d76c86f8ce04ec31a6e4d5871 100644 (file)
@@ -1396,7 +1396,7 @@ void start_background_queue(void)
                /* 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)) {
index 1069f95ed83ea7da81079201d2d970f3b586c7eb..3e4a8a858b5776ee8e1d3bab976326d442ba5e8a 100644 (file)
@@ -167,7 +167,7 @@ int count_all_current_connections(void)
 ****************************************************************************/
 
 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,23 +178,7 @@ BOOL claim_connection(connection_struct *conn, const char *name,
                return False;
        }
        
-       /*
-        * Enforce the max connections parameter.
-        */
-
-       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));
+       DEBUG(5,("claiming %s\n",name));
 
        make_conn_key(conn, name, &kbuf, &key);
 
index 7aa97250629378281b3b138a999719bd19a47878..92c392b3666a47d8ccf7d4e189e97002eb90bd7e 100644 (file)
@@ -584,7 +584,8 @@ int reply_negprot(connection_struct *conn,
           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++) {
index 3a2895cfcb2bf428a4670533fb300050648f331d..fc1faa9d36c4e095ecd5e8f2ea08acd5cbe63556 100644 (file)
@@ -1040,7 +1040,7 @@ extern void build_options(BOOL screen);
        /* 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
index 5b087fd5833c8e8d7adc30e680172fd2dac94525..2b8422369587008c6f07147396f09f0d1fe18e9f 100644 (file)
@@ -989,17 +989,31 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
        }
 
 /* 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 */