source4 smbd process: pass the fatal flag to terminate
authorGary Lockyer <gary@catalyst.net.nz>
Mon, 3 Sep 2018 22:09:38 +0000 (10:09 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 23 Nov 2018 07:25:19 +0000 (08:25 +0100)
Pass the fatal flag supplied to task_server_terminate to the process
task_terminate method.  It will be used by the task_terminate methods to
set an appropriate exit code.  The process_prefork model will use a non
zero exit code to indicate that the process should be restarted.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/smbd/process_model.h
source4/smbd/process_prefork.c
source4/smbd/process_single.c
source4/smbd/process_standard.c
source4/smbd/service_stream.c
source4/smbd/service_task.c

index 17d70254cf2d06cf8bddf9abfc3e2e493c18c603..2a226cef8cbd33ec5b2636d7ea8365d955982c28 100644 (file)
@@ -69,7 +69,8 @@ struct model_ops {
        void (*terminate)(struct tevent_context *,
                          struct loadparm_context *lp_ctx,
                          const char *reason,
-                         void * process_context);
+                         bool fatal,
+                         void *process_context);
 
        /* function to set a title for the connection or task */
        void (*set_title)(struct tevent_context *, const char *title);
index 4423b4674e4880736e3bf38204e1300992c074dd..c470820efb8e0286459efc88f99fa0e93620ea18 100644 (file)
@@ -534,6 +534,7 @@ static void prefork_new_task(
 static void prefork_terminate(struct tevent_context *ev,
                              struct loadparm_context *lp_ctx,
                              const char *reason,
+                             bool fatal,
                              void *process_context)
 {
        DBG_DEBUG("called with reason[%s]\n", reason);
index 174c15728125d3ab034a0cfbd546031891ec5489..061f09673dd68acbe91fbced1cf1298b26d43913 100644 (file)
@@ -124,6 +124,7 @@ static void single_new_task(struct tevent_context *ev,
 static void single_terminate(struct tevent_context *ev,
                             struct loadparm_context *lp_ctx,
                             const char *reason,
+                            bool fatal,
                             void *process_context)
 {
        DBG_NOTICE("single_terminate: reason[%s]\n",reason);
index 91dfa9753c5494e7d87f781a41feb6f7c4ce220e..536a6be30078ca4a41536e8d3d3854dc7182a6f5 100644 (file)
@@ -513,6 +513,7 @@ static void standard_new_task(struct tevent_context *ev,
 static void standard_terminate(struct tevent_context *ev,
                               struct loadparm_context *lp_ctx,
                               const char *reason,
+                              bool fatal,
                               void *process_context)
 {
        struct process_context *proc_ctx = NULL;
index fc996d942e6808b60b46f4bed7ee5162d076455d..336a0cb32aa7aaa79aca5176bd079cd95e778c09 100644 (file)
@@ -57,6 +57,7 @@ void stream_terminate_connection(struct stream_connection *srv_conn, const char
        const struct model_ops *model_ops = srv_conn->model_ops;
        struct loadparm_context *lp_ctx = srv_conn->lp_ctx;
        void *process_context = srv_conn->process_context;
+       bool fatal = true;
        TALLOC_CTX *frame = NULL;
 
        if (!reason) reason = "unknown reason";
@@ -91,7 +92,7 @@ void stream_terminate_connection(struct stream_connection *srv_conn, const char
        srv_conn->event.fde = NULL;
        imessaging_cleanup(srv_conn->msg_ctx);
        TALLOC_FREE(srv_conn);
-       model_ops->terminate(event_ctx, lp_ctx, reason, process_context);
+       model_ops->terminate(event_ctx, lp_ctx, reason, fatal, process_context);
        TALLOC_FREE(frame);
 }
 
index 15e480ec043c22f7447db6ea618b9c0dec4b3072..cb1f4d5ad1fe62f7a8e726183900073dc2fdcf91 100644 (file)
@@ -54,8 +54,8 @@ void task_server_terminate(struct task_server *task, const char *reason, bool fa
 
        imessaging_cleanup(task->msg_ctx);
 
-       model_ops->terminate(event_ctx, task->lp_ctx, reason,
-                            task->process_context);
+       model_ops->terminate(
+           event_ctx, task->lp_ctx, reason, fatal, task->process_context);
        /* don't free this above, it might contain the 'reason' being printed */
        talloc_free(task);
 }