process_standard: Honour proc_ctx->inhibit_fork_on_accept
authorGary Lockyer <gary@catalyst.net.nz>
Thu, 19 Oct 2017 02:15:33 +0000 (15:15 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 19 Oct 2017 03:33:10 +0000 (05:33 +0200)
This allows the service to control if it should fork per accept() without needing
to replace the whole process model with process_single.

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

index f5922c8d91cb7087b60fb04997c6743e90d76124..a17a1ec3b067857ac774998b483413148f81b512 100644 (file)
@@ -263,6 +263,21 @@ static void standard_accept_connection(
        proc_ctx = talloc_get_type_abort(process_context,
                                         struct process_context);
 
+       if (proc_ctx->inhibit_fork_on_accept) {
+               pid = getpid();
+               /*
+                * Service does not support forking a new process on a
+                * new connection, either it's maintaining shared
+                * state or the overhead of forking a new process is a
+                * significant fraction of the response time.
+                */
+               talloc_steal(private_data, sock2);
+               new_conn(ev, lp_ctx, sock2,
+                        cluster_id(pid, socket_get_fd(sock2)), private_data,
+                        process_context);
+               return;
+       }
+
        state = setup_standard_child_pipe(ev, NULL);
        if (state == NULL) {
                return;