diff options
author | Volker Lendecke <vlendec@samba.org> | 2007-05-27 16:34:49 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:22:51 -0500 |
commit | 4afe37d431b6eb475769a2057025da9aa8d1bb14 (patch) | |
tree | ec5f24f1f5257403269451e420f79df95ce4aa43 /source/smbd | |
parent | 3452a870d58cdddf03ddf6ee698bca8416e05cbf (diff) | |
download | samba-4afe37d431b6eb475769a2057025da9aa8d1bb14.tar.gz samba-4afe37d431b6eb475769a2057025da9aa8d1bb14.tar.xz samba-4afe37d431b6eb475769a2057025da9aa8d1bb14.zip |
r23168: Move the lp_max_connections() into service.c.
Diffstat (limited to 'source/smbd')
-rw-r--r-- | source/smbd/connection.c | 20 | ||||
-rw-r--r-- | source/smbd/negprot.c | 3 | ||||
-rw-r--r-- | source/smbd/server.c | 2 | ||||
-rw-r--r-- | source/smbd/service.c | 26 |
4 files changed, 25 insertions, 26 deletions
diff --git a/source/smbd/connection.c b/source/smbd/connection.c index 1069f95ed83..3e4a8a858b5 100644 --- a/source/smbd/connection.c +++ b/source/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/source/smbd/negprot.c b/source/smbd/negprot.c index 7aa97250629..92c392b3666 100644 --- a/source/smbd/negprot.c +++ b/source/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/source/smbd/server.c b/source/smbd/server.c index 3a2895cfcb2..fc1faa9d36c 100644 --- a/source/smbd/server.c +++ b/source/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/source/smbd/service.c b/source/smbd/service.c index 5b087fd5833..2b842236958 100644 --- a/source/smbd/service.c +++ b/source/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 */ |