diff options
author | Uri Simchoni <urisimchoni@gmail.com> | 2015-07-13 21:42:57 +0300 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2015-07-16 01:45:19 +0200 |
commit | 2c1c567ee1a59fa7bf09be0ed0554d2dc01cd0b9 (patch) | |
tree | 888760bcd73baaa6810f6cd1cfd86cf810cf158d /source3 | |
parent | c10e24e1c77a7ec1e020e2b61900eff05daffa29 (diff) | |
download | samba-2c1c567ee1a59fa7bf09be0ed0554d2dc01cd0b9.tar.gz |
winbindd: shorten client list scan
Counting on the client list being sorted by last access time,
the list scan for removing timed-out clients is shortened - once
the list is scanned oldest to newest, and once a non-timed-out
client is found, the scan can stop.
Also, finding the oldest idle client for removing an idle client
is simplified - oldest idle client is last idle client.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11397
Signed-off-by: Uri Simchoni <urisimchoni@gmail.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Jul 16 01:45:20 CEST 2015 on sn-devel-104
Diffstat (limited to 'source3')
-rw-r--r-- | source3/winbindd/winbindd.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 620fd3fb8b6..c878ce2e220 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -1086,16 +1086,13 @@ static bool client_is_idle(struct winbindd_cli_state *state) { static bool remove_idle_client(void) { struct winbindd_cli_state *state, *remove_state = NULL; - time_t last_access = 0; int nidle = 0; for (state = winbindd_client_list(); state; state = state->next) { if (client_is_idle(state)) { nidle++; - if (!last_access || state->last_access < last_access) { - last_access = state->last_access; - remove_state = state; - } + /* list is sorted by access time */ + remove_state = state; } } @@ -1117,14 +1114,14 @@ static bool remove_idle_client(void) static void remove_timed_out_clients(void) { - struct winbindd_cli_state *state, *next = NULL; + struct winbindd_cli_state *state, *prev = NULL; time_t curr_time = time(NULL); int timeout_val = lp_winbind_request_timeout(); - for (state = winbindd_client_list(); state; state = next) { + for (state = winbindd_client_list_tail(); state; state = prev) { time_t expiry_time; - next = state->next; + prev = winbindd_client_list_prev(state); expiry_time = state->last_access + timeout_val; if (curr_time > expiry_time) { @@ -1140,6 +1137,10 @@ static void remove_timed_out_clients(void) (unsigned int)state->pid)); } remove_client(state); + } else { + /* list is sorted, previous clients in + list are newer */ + break; } } } |