summaryrefslogtreecommitdiff
path: root/source3/winbindd/winbindd.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2014-07-25 12:46:46 -0700
committerJeremy Allison <jra@samba.org>2014-07-29 23:31:14 +0200
commitf9588675ea3cb2f1fabd07a4ea8b2138d65aee83 (patch)
tree96f1013ee89c0672d15bd07c49bae3308df73eab /source3/winbindd/winbindd.c
parent2535803627687f390cae6a95e88f70ff4d6cc67a (diff)
downloadsamba-f9588675ea3cb2f1fabd07a4ea8b2138d65aee83.tar.gz
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 <jra@samba.org> Reviewed-by: Ira Cooper <ira@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Jul 29 23:31:14 CEST 2014 on sn-devel-104
Diffstat (limited to 'source3/winbindd/winbindd.c')
-rw-r--r--source3/winbindd/winbindd.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index a51a172973b..caa9ed127dd 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -1031,6 +1031,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;
@@ -1056,6 +1091,7 @@ static void winbindd_listen_fde_handler(struct tevent_context *ev,
break;
}
}
+ remove_timed_out_clients();
new_connection(s->fd, s->privileged);
}