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;
}
}
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) {
(unsigned int)state->pid));
}
remove_client(state);
+ } else {
+ /* list is sorted, previous clients in
+ list are newer */
+ break;
}
}
}