diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index eab62a7..7db0d42 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -961,6 +961,32 @@ struct winbindd_listen_state { int fd; }; +static void winbindd_check_and_clean_dead_clients() { + + struct winbindd_cli_state *state = NULL; + int count = 0; + int i = 0; + + struct winbindd_cli_state* state_arr[1024]; + for (i = 0; i < 1024; i++) { + state_arr[i] = NULL; + } + + for (state = winbindd_client_list(); state; state = state->next) { + if (state->pid && (kill(state->pid, 0) == -1) && (count<1024)) { + state_arr[count++] = state; + } + } + + if (count) { + for (i = 0; i < count; i++) { + if (state_arr[i]) { + remove_client(state_arr[i]); + } + } + } +} + static void winbindd_listen_fde_handler(struct tevent_context *ev, struct tevent_fd *fde, uint16_t flags, @@ -982,6 +1008,11 @@ static void winbindd_listen_fde_handler(struct tevent_context *ev, } } new_connection(s->fd, s->privileged); + if (winbindd_num_clients() > (lp_winbind_max_clients()/4) ) { + DEBUG(5,("winbindd: Checking for dead clients. \n")); + winbindd_check_and_clean_dead_clients(); + } + } /*