]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
process_standard: Move child pipe setup further down standard_accept_connection()
authorGary Lockyer <gary@catalyst.net.nz>
Thu, 19 Oct 2017 02:14:16 +0000 (15:14 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 19 Oct 2017 03:33:10 +0000 (05:33 +0200)
This avoids cleaning up on error from accept() but more importantly
allows a future mode that acts like process_single and so has no child.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/smbd/process_standard.c

index 4d2aa95104fd97a1700ded68198021149a927740..f5922c8d91cb7087b60fb04997c6743e90d76124 100644 (file)
@@ -248,28 +248,25 @@ static void standard_accept_connection(
        struct tevent_signal *se = NULL;
        struct process_context *proc_ctx = NULL;
 
-       state = setup_standard_child_pipe(ev, NULL);
-       if (state == NULL) {
-               return;
-       }
 
        /* accept an incoming connection. */
        status = socket_accept(sock, &sock2);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("standard_accept_connection: accept: %s\n",
-                        nt_errstr(status)));
+                       nt_errstr(status)));
                /* this looks strange, but is correct. We need to throttle things until
                   the system clears enough resources to handle this new socket */
                sleep(1);
-               close(state->to_parent_fd);
-               state->to_parent_fd = -1;
-               TALLOC_FREE(state);
                return;
        }
 
        proc_ctx = talloc_get_type_abort(process_context,
                                         struct process_context);
 
+       state = setup_standard_child_pipe(ev, NULL);
+       if (state == NULL) {
+               return;
+       }
        pid = fork();
 
        if (pid != 0) {