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 | 14e25f10d6a3da34fb8b29c4331571efa11ee3b8 (patch) | |
tree | 7369abad85080ebb67627e264bfe00a7b3777f0c /source3/smbd | |
parent | f3c477c631e7318ccaa6f277731b721a462112b8 (diff) | |
download | samba-14e25f10d6a3da34fb8b29c4331571efa11ee3b8.tar.gz samba-14e25f10d6a3da34fb8b29c4331571efa11ee3b8.tar.bz2 samba-14e25f10d6a3da34fb8b29c4331571efa11ee3b8.zip |
r23168: Move the lp_max_connections() into service.c.
(This used to be commit 4afe37d431b6eb475769a2057025da9aa8d1bb14)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/connection.c | 20 | ||||
-rw-r--r-- | source3/smbd/negprot.c | 3 | ||||
-rw-r--r-- | source3/smbd/server.c | 2 | ||||
-rw-r--r-- | source3/smbd/service.c | 26 |
4 files changed, 25 insertions, 26 deletions
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 */ |