winbind: only pass needed args to child_read_request
authorDavid Disseldorp <ddiss@samba.org>
Thu, 14 Mar 2013 16:36:36 +0000 (17:36 +0100)
committerDavid Disseldorp <ddiss@samba.org>
Mon, 15 Apr 2013 16:15:22 +0000 (18:15 +0200)
The socket and request are the only arguments required, the entire
winbind child state structure is not needed.
This allows for the separation of the request and response structures,
which will be done as part of making winbind_child asynchronous.

source3/winbindd/winbindd_dual.c

index 60b15e3fe45b55d649148a02618a39f6e168725d..0cd178567f7de547897bdc0d3728741968cc454a 100644 (file)
@@ -48,42 +48,34 @@ static struct winbindd_child *winbindd_children = NULL;
 
 /* Read some data from a client connection */
 
-static NTSTATUS child_read_request(struct winbindd_cli_state *state)
+static NTSTATUS child_read_request(int sock, struct winbindd_request *wreq)
 {
        NTSTATUS status;
 
-       /* Read data */
-
-       status = read_data(state->sock, (char *)state->request,
-                          sizeof(*state->request));
-
+       status = read_data(sock, (char *)wreq, sizeof(*wreq));
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(3, ("child_read_request: read_data failed: %s\n",
                          nt_errstr(status)));
                return status;
        }
 
-       if (state->request->extra_len == 0) {
-               state->request->extra_data.data = NULL;
+       if (wreq->extra_len == 0) {
+               wreq->extra_data.data = NULL;
                return NT_STATUS_OK;
        }
 
-       DEBUG(10, ("Need to read %d extra bytes\n", (int)state->request->extra_len));
+       DEBUG(10, ("Need to read %d extra bytes\n", (int)wreq->extra_len));
 
-       state->request->extra_data.data =
-               SMB_MALLOC_ARRAY(char, state->request->extra_len + 1);
-
-       if (state->request->extra_data.data == NULL) {
+       wreq->extra_data.data = SMB_MALLOC_ARRAY(char, wreq->extra_len + 1);
+       if (wreq->extra_data.data == NULL) {
                DEBUG(0, ("malloc failed\n"));
                return NT_STATUS_NO_MEMORY;
        }
 
        /* Ensure null termination */
-       state->request->extra_data.data[state->request->extra_len] = '\0';
-
-       status= read_data(state->sock, state->request->extra_data.data,
-                         state->request->extra_len);
+       wreq->extra_data.data[wreq->extra_len] = '\0';
 
+       status = read_data(sock, wreq->extra_data.data, wreq->extra_len);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("Could not read extra data: %s\n",
                          nt_errstr(status)));
@@ -1539,7 +1531,7 @@ static bool fork_domain_child(struct winbindd_child *child)
                }
 
                /* fetch a request from the main daemon */
-               status = child_read_request(&state);
+               status = child_read_request(state.sock, state.request);
 
                if (!NT_STATUS_IS_OK(status)) {
                        /* we lost contact with our parent */