Remove "winbindd_request" and "winbindd_response" from winbindd_cli_state
authorVolker Lendecke <vl@samba.org>
Sun, 14 Jun 2009 10:58:19 +0000 (12:58 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 14 Jun 2009 20:22:10 +0000 (22:22 +0200)
This shrinks the memory footprint of an idle client by 5592 bytes to 60 bytes
on my 32-bit box.

source3/winbindd/winbindd.c
source3/winbindd/winbindd.h
source3/winbindd/winbindd_dual.c

index 9cc1bf270180bbbb344c98dd924c17261fc3e9e9..0a73c0ebc6c26c02066e220db49e762a011f60b8 100644 (file)
@@ -531,11 +531,6 @@ static void process_request(struct winbindd_cli_state *state)
        struct winbindd_dispatch_table *table = dispatch_table;
        struct winbindd_async_dispatch_table *atable;
 
-       ZERO_STRUCTP(state->response);
-
-       state->response->result = WINBINDD_PENDING;
-       state->response->length = sizeof(struct winbindd_response);
-
        state->mem_ctx = talloc_init("winbind request");
        if (state->mem_ctx == NULL)
                return;
@@ -570,6 +565,16 @@ static void process_request(struct winbindd_cli_state *state)
                return;
        }
 
+       state->response = talloc_zero(state->mem_ctx,
+                                     struct winbindd_response);
+       if (state->response == NULL) {
+               DEBUG(10, ("talloc failed\n"));
+               remove_client(state);
+               return;
+       }
+       state->response->result = WINBINDD_PENDING;
+       state->response->length = sizeof(struct winbindd_response);
+
        for (table = dispatch_table; table->fn; table++) {
                if (state->request->cmd == table->cmd) {
                        DEBUG(10,("process_request: request fn %s\n",
@@ -709,7 +714,6 @@ static void new_connection(int listen_sock, bool privileged)
        }
 
        state->sock = sock;
-       state->response = &state->_response;
 
        state->out_queue = tevent_queue_create(state, "winbind client reply");
        if (state->out_queue == NULL) {
index 4b4fc04d6d5593e4cd13a936bc026a9ddb115415..804c0afa5d78f6649da4e7ac8686268235cbc992 100644 (file)
@@ -58,10 +58,8 @@ struct winbindd_cli_state {
        NTSTATUS (*recv_fn)(struct tevent_req *req, TALLOC_CTX *mem_ctx,
                            struct winbindd_response **presp);
        struct winbindd_request *request;         /* Request from client */
-       struct winbindd_request _request;
        struct tevent_queue *out_queue;
-       struct winbindd_response *response;
-       struct winbindd_response _response;        /* Respose to client */
+       struct winbindd_response *response;        /* Respose to client */
        bool getpwent_initialized;                /* Has getpwent_state been
                                                   * initialized? */
        bool getgrent_initialized;                /* Has getgrent_state been
index 3e0d956a74b0f5735691233e10ec8477de3954ac..92f0d60817e474725b0cfa6fcdac8e44304bbb7f 100644 (file)
@@ -1316,6 +1316,8 @@ static bool fork_domain_child(struct winbindd_child *child)
 {
        int fdpair[2];
        struct winbindd_cli_state state;
+       struct winbindd_request request;
+       struct winbindd_response response;
        struct winbindd_domain *primary_domain = NULL;
 
        if (child->domain) {
@@ -1333,8 +1335,8 @@ static bool fork_domain_child(struct winbindd_child *child)
 
        ZERO_STRUCT(state);
        state.pid = sys_getpid();
-       state.request = &state._request;
-       state.response = &state._response;
+       state.request = &request;
+       state.response = &response;
 
        child->pid = sys_fork();