2 Unix SMB/CIFS implementation.
5 Copyright (C) Simo Sorce <idra@samba.org> 2011
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "system/network.h"
24 enum pf_worker_status
{
37 struct pf_worker_data
{
39 enum pf_worker_status status
;
44 enum pf_server_cmds cmds
;
48 typedef int (prefork_main_fn_t
)(struct tevent_context
*ev
,
49 struct pf_worker_data
*pf
,
57 /* ==== Functions used by controlling process ==== */
59 bool prefork_create_pool(struct tevent_context
*ev_ctx
,
60 TALLOC_CTX
*mem_ctx
, int listen_fd
,
61 int min_children
, int max_children
,
62 prefork_main_fn_t
*main_fn
, void *private_data
,
63 struct prefork_pool
**pf_pool
);
64 int prefork_expand_pool(struct prefork_pool
*pfp
, int new_max
);
66 int prefork_add_children(struct tevent_context
*ev_ctx
,
67 struct prefork_pool
*pfp
,
69 int prefork_retire_children(struct prefork_pool
*pfp
,
70 int num_children
, time_t age_limit
);
71 int prefork_count_active_children(struct prefork_pool
*pfp
, int *total
);
72 bool prefork_mark_pid_dead(struct prefork_pool
*pfp
, pid_t pid
);
73 void prefork_increase_allowed_clients(struct prefork_pool
*pfp
, int max
);
74 void prefork_reset_allowed_clients(struct prefork_pool
*pfp
);
76 /* ==== Functions used by children ==== */
78 int prefork_wait_for_client(struct pf_worker_data
*pf
,
79 int lock_fd
, int listen_fd
,
80 struct sockaddr
*addr
,
81 socklen_t
*addrlen
, int *fd
);
83 struct tevent_req
*prefork_listen_send(TALLOC_CTX
*mem_ctx
,
84 struct tevent_context
*ev
,
85 struct pf_worker_data
*pf
,
86 int lock_fd
, int listen_fd
,
87 struct sockaddr
*addr
,
89 int prefork_listen_recv(struct tevent_req
*req
, int *fd
);