From 14e25f10d6a3da34fb8b29c4331571efa11ee3b8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 27 May 2007 16:34:49 +0000 Subject: r23168: Move the lp_max_connections() into service.c. (This used to be commit 4afe37d431b6eb475769a2057025da9aa8d1bb14) --- source3/printing/printing.c | 2 +- source3/smbd/connection.c | 20 ++------------------ source3/smbd/negprot.c | 3 ++- source3/smbd/server.c | 2 +- source3/smbd/service.c | 26 ++++++++++++++++++++------ 5 files changed, 26 insertions(+), 27 deletions(-) (limited to 'source3') diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 780880cbe7..3453598480 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -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)) { diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c index 1069f95ed8..3e4a8a858b 100644 --- a/source3/smbd/connection.c +++ b/source3/smbd/connection.c @@ -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); diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 7aa9725062..92c392b366 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -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++) { diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 3a2895cfcb..fc1faa9d36 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -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 diff --git a/source3/smbd/service.c b/source3/smbd/service.c index 5b087fd583..2b84223695 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -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 */ -- cgit