Avoid scanning the client list when a client exits
authorVolker Lendecke <vl@samba.org>
Mon, 25 May 2009 18:28:38 +0000 (20:28 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 14 Jun 2009 09:25:48 +0000 (11:25 +0200)
source3/winbindd/winbindd.c
source3/winbindd/winbindd.h

index ca2377131de8312341881f55e00f32f1b118abc6..cc2a7cb2a7b7679e7a4609fea3f42ce075db5cf2 100644 (file)
@@ -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);
index ae688e251c078ac03507c37194f7e6efeb454116..419ab5079226cc20c9a396e8996fb816865a4079 100644 (file)
@@ -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' */