if (task != NULL && service_details->post_fork != NULL) {
service_details->post_fork(task, &pd);
}
+ if (task != NULL && service_details->before_loop != NULL) {
+ service_details->before_loop(task);
+ }
tevent_loop_wait(ev);
TALLOC_FREE(ev);
exit(0);
smb_set_close_on_exec(control_pipe[1]);
}
+ /*
+ * Note, we call this before the first
+ * prefork_fork_worker() in order to have
+ * a stable order of:
+ * task_init(master) -> before_loop(master)
+ * -> post_fork(worker) -> before_loop(worker)
+ *
+ * Otherwise we would have different behaviors
+ * between the first prefork_fork_worker() loop
+ * and restarting of died workers
+ */
+ if (task != NULL && service_details->before_loop != NULL) {
+ service_details->before_loop(task);
+ }
+
/*
* We are now free to spawn some worker processes
*/
irpc_add_name(task->msg_ctx, name);
TALLOC_FREE(ctx);
}
+ if (service_details->before_loop != NULL) {
+ service_details->before_loop(task);
+ }
tevent_loop_wait(ev2);
imessaging_dgm_unref_ev(ev2);
talloc_free(ev2);
struct process_details pd = initial_process_details;
service_details->post_fork(task, &pd);
}
+ if (task != NULL && service_details->before_loop != NULL) {
+ service_details->before_loop(task);
+ }
}
/*
service_details->post_fork(task, &pd);
}
+ if (task != NULL && service_details->before_loop != NULL) {
+ service_details->before_loop(task);
+ }
/* we can't return to the top level here, as that event context is gone,
so we now process events in the new event context until there are no
* immediately after the task_init.
*/
void (*post_fork) (struct task_server *, struct process_details *);
+ /*
+ * This is called before entering the tevent_loop_wait():
+ *
+ * Note that task_server->msg_ctx, task_server->event_ctx
+ * and maybe other fields might have changed compared to
+ * task_init()/post_fork(). The struct task_server pointer
+ * may also change!
+ *
+ * before loop processing this is called in this order:
+ * - standard process model
+ * task_init() -> post_fork() -> before_loop()
+ *
+ * - single process model
+ * task_init() -> post_fork() -> before_loop()
+ *
+ * - prefork process model, inhibit_pre_fork = true
+ * task_init() -> post_fork() -> before_loop()
+ *
+ * - prefork process model, inhibit_pre_fork = false
+ * In the service master process:
+ * task_init(master) -> before_loop(master)
+ *
+ * After each service worker has forked:
+ * post_fork(worker) -> before_loop(worker)
+ *
+ * This gives the service a chance to register messaging
+ * and/or event handlers on the correct contexts.
+ */
+ void (*before_loop) (struct task_server *);
};
NTSTATUS samba_service_init(void);