1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/*
Unix SMB/CIFS implementation.
Common server globals
Copyright (C) Simo Sorce <idra@samba.org> 2011
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "system/network.h"
#include <tevent.h>
enum pf_worker_status {
PF_WORKER_NONE = 0,
PF_WORKER_IDLE,
PF_WORKER_ACCEPTING,
PF_WORKER_BUSY,
PF_WORKER_EXITING
};
enum pf_server_cmds {
PF_SRV_MSG_NONE = 0,
PF_SRV_MSG_EXIT
};
struct pf_worker_data {
pid_t pid;
enum pf_worker_status status;
time_t started;
time_t last_used;
int num_clients;
enum pf_server_cmds cmds;
int allowed_clients;
};
typedef int (prefork_main_fn_t)(struct tevent_context *ev,
struct pf_worker_data *pf,
int listen_fd_size,
int *listen_fds,
int lock_fd,
void *private_data);
struct prefork_pool;
/* ==== Functions used by controlling process ==== */
bool prefork_create_pool(struct tevent_context *ev_ctx, TALLOC_CTX *mem_ctx,
int listen_fd_size, int *listen_fds,
int min_children, int max_children,
prefork_main_fn_t *main_fn, void *private_data,
struct prefork_pool **pf_pool);
int prefork_expand_pool(struct prefork_pool *pfp, int new_max);
int prefork_add_children(struct tevent_context *ev_ctx,
struct prefork_pool *pfp,
int num_children);
int prefork_retire_children(struct prefork_pool *pfp,
int num_children, time_t age_limit);
int prefork_count_active_children(struct prefork_pool *pfp, int *total);
bool prefork_mark_pid_dead(struct prefork_pool *pfp, pid_t pid);
void prefork_increase_allowed_clients(struct prefork_pool *pfp, int max);
void prefork_reset_allowed_clients(struct prefork_pool *pfp);
void prefork_send_signal_to_all(struct prefork_pool *pfp, int signal_num);
/* ==== Functions used by children ==== */
struct tevent_req *prefork_listen_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct pf_worker_data *pf,
int listen_fd_size,
int *listen_fds,
int lock_fd,
struct sockaddr *addr,
socklen_t *addrlen);
int prefork_listen_recv(struct tevent_req *req, int *fd);
|