From: Jeremy Allison Date: Fri, 25 Jul 2014 19:46:46 +0000 (-0700) Subject: s3: winbindd: On new client connect, prune idle or hung connections older than "winbi... X-Git-Tag: samba-4.0.22~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d14c83e072045cd2f638c4e4484a9f2ea71b9460;p=thirdparty%2Fsamba.git s3: winbindd: On new client connect, prune idle or hung connections older than "winbind request timeout" Bug 3204 winbindd: Exceeding 200 client connections, no idle connection found https://bugzilla.samba.org/show_bug.cgi?id=3204 Signed-off-by: Jeremy Allison Reviewed-by: Ira Cooper Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Tue Jul 29 23:31:14 CEST 2014 on sn-devel-104 (cherry picked from commit f9588675ea3cb2f1fabd07a4ea8b2138d65aee83) Autobuild-User(v4-0-test): Karolin Seeger Autobuild-Date(v4-0-test): Tue Sep 2 22:45:38 CEST 2014 on sn-devel-104 --- diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 839655ee3a6..69aa9a72f71 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -969,6 +969,41 @@ static bool remove_idle_client(void) return False; } +/* + * Terminate all clients whose requests have taken longer than + * "winbind request timeout" seconds to process, or have been + * idle for more than "winbind request timeout" seconds. + */ + +static void remove_timed_out_clients(void) +{ + struct winbindd_cli_state *state, *next = NULL; + time_t curr_time = time(NULL); + int timeout_val = lp_winbind_request_timeout(); + + for (state = winbindd_client_list(); state; state = next) { + time_t expiry_time; + + next = state->next; + expiry_time = state->last_access + timeout_val; + + if (curr_time > expiry_time) { + if (client_is_idle(state)) { + DEBUG(5,("Idle client timed out, " + "shutting down sock %d, pid %u\n", + state->sock, + (unsigned int)state->pid)); + } else { + DEBUG(5,("Client request timed out, " + "shutting down sock %d, pid %u\n", + state->sock, + (unsigned int)state->pid)); + } + remove_client(state); + } + } +} + struct winbindd_listen_state { bool privileged; int fd; @@ -994,6 +1029,7 @@ static void winbindd_listen_fde_handler(struct tevent_context *ev, break; } } + remove_timed_out_clients(); new_connection(s->fd, s->privileged); }