From eaaaea01e061927d16eca1c7472de108bf0edce3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 25 May 2009 20:28:38 +0200 Subject: Avoid scanning the client list when a client exits --- source3/winbindd/winbindd.c | 25 ++++++------------------- source3/winbindd/winbindd.h | 1 - 2 files changed, 6 insertions(+), 20 deletions(-) (limited to 'source3') diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index ca2377131d..cc2a7cb2a7 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -29,6 +29,8 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND +static void remove_client(struct winbindd_cli_state *state); + static bool opt_nocache = False; static bool interactive = False; @@ -628,7 +630,7 @@ static void request_finished(struct winbindd_cli_state *state) state->out_queue, state->sock, &state->response); if (req == NULL) { - state->finished = true; + remove_client(state); return; } tevent_req_set_callback(req, winbind_client_response_written, state); @@ -646,7 +648,7 @@ static void winbind_client_response_written(struct tevent_req *req) if (ret == -1) { DEBUG(2, ("Could not write response to client: %s\n", strerror(err))); - state->finished = true; + remove_client(state); return; } @@ -655,7 +657,7 @@ static void winbind_client_response_written(struct tevent_req *req) req = wb_req_read_send(state, winbind_event_context(), state->sock, WINBINDD_MAX_EXTRA_DATA); if (req == NULL) { - state->finished = true; + remove_client(state); return; } tevent_req_set_callback(req, winbind_client_request_read, state); @@ -744,7 +746,7 @@ static void winbind_client_request_read(struct tevent_req *req) if (ret == -1) { DEBUG(2, ("Could not read client request: %s\n", strerror(err))); - state->finished = true; + remove_client(state); return; } process_request(state); @@ -1265,27 +1267,12 @@ int main(int argc, char **argv, char **envp) TALLOC_FREE(frame); /* Loop waiting for requests */ while (1) { - struct winbindd_cli_state *state; - frame = talloc_stackframe(); /* refresh the trusted domain cache */ rescan_trusted_domains(); - /* Dispose of client connection if it is marked as - finished */ - state = winbindd_client_list(); - while (state) { - struct winbindd_cli_state *next = state->next; - - if (state->finished) { - remove_client(state); - } - - state = next; - } - process_loop(); TALLOC_FREE(frame); diff --git a/source3/winbindd/winbindd.h b/source3/winbindd/winbindd.h index ae688e251c..419ab50792 100644 --- a/source3/winbindd/winbindd.h +++ b/source3/winbindd/winbindd.h @@ -51,7 +51,6 @@ struct winbindd_cli_state { struct winbindd_cli_state *prev, *next; /* Linked list pointers */ int sock; /* Open socket from client */ pid_t pid; /* pid of client */ - bool finished; /* Can delete from list */ bool write_extra_data; /* Write extra_data field */ time_t last_access; /* Time of last access (read or write) */ bool privileged; /* Is the client 'privileged' */ -- cgit