ctdb-common: Map ENOENT for a missing event script to ENOEXEC
[samba4-gss.git] / source4 / samba / service.h
blob35e3f519154c718d26fdd765901bf3a5187e9c52
1 /*
2 Unix SMB/CIFS implementation.
4 SERVER SERVICE code
6 Copyright (C) Andrew Tridgell 2003-2005
7 Copyright (C) Stefan (metze) Metzmacher 2004
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef __SERVICE_H__
24 #define __SERVICE_H__
27 #include "samba/service_stream.h"
28 #include "samba/service_task.h"
30 struct process_details {
31 unsigned int instances;
34 static const struct process_details initial_process_details = {
35 .instances = 0
38 struct service_details {
40 * Prevent the standard process model from forking a new worker
41 * process when accepting a new connection. Do this when the service
42 * relies on shared state, or the over-head of forking would be a
43 * significant part of the response time
45 bool inhibit_fork_on_accept;
47 * Prevent the pre-fork process model from pre-forking any worker
48 * processes. In this mode pre-fork is equivalent to standard with
49 * inhibit_fork_on_accept set.
51 bool inhibit_pre_fork;
53 * Initialise the server task.
55 NTSTATUS (*task_init) (struct task_server *);
57 * post fork processing this is called:
58 * - standard process model
59 * immediately after the task_init.
61 * - single process model
62 * immediately after the task_init
64 * - prefork process model, inhibit_pre_fork = true
65 * immediately after the task_init
67 * - prefork process model, inhibit_pre_fork = false
68 * after each service worker has forked. It is not run on the
69 * service master process.
71 * The post fork hook is not called in the standard model if a new
72 * process is forked on a new connection. It is instead called
73 * immediately after the task_init.
75 void (*post_fork) (struct task_server *, struct process_details *);
77 * This is called before entering the tevent_loop_wait():
79 * Note that task_server->msg_ctx, task_server->event_ctx
80 * and maybe other fields might have changed compared to
81 * task_init()/post_fork(). The struct task_server pointer
82 * may also change!
84 * before loop processing this is called in this order:
85 * - standard process model
86 * task_init() -> post_fork() -> before_loop()
88 * - single process model
89 * task_init() -> post_fork() -> before_loop()
91 * - prefork process model, inhibit_pre_fork = true
92 * task_init() -> post_fork() -> before_loop()
94 * - prefork process model, inhibit_pre_fork = false
95 * In the service master process:
96 * task_init(master) -> before_loop(master)
98 * After each service worker has forked:
99 * post_fork(worker) -> before_loop(worker)
101 * This gives the service a chance to register messaging
102 * and/or event handlers on the correct contexts.
104 void (*before_loop) (struct task_server *);
107 NTSTATUS samba_service_init(void);
109 #include "samba/service_proto.h"
111 #endif /* __SERVICE_H__ */