1 #ifndef MASTER_SERVICE_PRIVATE_H
2 #define MASTER_SERVICE_PRIVATE_H
3 
4 #include "master-interface.h"
5 #include "master-service.h"
6 
7 struct master_service_haproxy_conn;
8 
9 struct master_service_listener {
10 	struct master_service *service;
11 	char *name;
12 
13 	/* settings */
14 	bool ssl;
15 	bool haproxy;
16 
17 	/* state */
18 	bool closed;
19 	int fd;
20 	struct io *io;
21 };
22 
23 struct master_service {
24 	struct ioloop *ioloop;
25 
26 	char *name;
27 	char *configured_name;
28 	char *getopt_str;
29 	enum master_service_flags flags;
30 
31 	int argc;
32 	char **argv;
33 
34 	const char *version_string;
35 	char *config_path;
36 	ARRAY_TYPE(const_string) config_overrides;
37 	int config_fd;
38 	int syslog_facility;
39 	data_stack_frame_t datastack_frame_id;
40 
41 	struct master_service_listener *listeners;
42 	unsigned int socket_count;
43 
44 	struct io *io_status_write, *io_status_error;
45 	unsigned int service_count_left;
46 	unsigned int total_available_count;
47 	unsigned int process_limit;
48 	unsigned int process_min_avail;
49 	unsigned int idle_kill_secs;
50 
51 	struct master_status master_status;
52 	unsigned int last_sent_status_avail_count;
53 	time_t last_sent_status_time;
54 	struct timeout *to_status;
55 
56 	bool (*idle_die_callback)(void);
57 	void (*die_callback)(void);
58 	struct timeout *to_die;
59 
60 	master_service_avail_overflow_callback_t *avail_overflow_callback;
61 	struct timeout *to_overflow_state, *to_overflow_call;
62 
63 	struct master_login *login;
64 
65 	master_service_connection_callback_t *callback;
66 
67 	pool_t set_pool;
68 	const struct master_service_settings *set;
69 	struct setting_parser_context *set_parser;
70 
71 	struct ssl_iostream_context *ssl_ctx;
72 	time_t ssl_params_last_refresh;
73 
74 	struct stats_client *stats_client;
75 	struct master_service_haproxy_conn *haproxy_conns;
76 
77 	bool killed:1;
78 	bool stopping:1;
79 	bool keep_environment:1;
80 	bool log_directly:1;
81 	bool initial_status_sent:1;
82 	bool die_with_master:1;
83 	bool call_avail_overflow:1;
84 	bool config_path_changed_with_param:1;
85 	bool want_ssl_server:1;
86 	bool ssl_ctx_initialized:1;
87 	bool config_path_from_master:1;
88 	bool log_initialized:1;
89 	bool init_finished:1;
90 };
91 
92 void master_service_io_listeners_add(struct master_service *service);
93 void master_status_update(struct master_service *service);
94 void master_service_close_config_fd(struct master_service *service);
95 
96 void master_service_io_listeners_remove(struct master_service *service);
97 void master_service_ssl_io_listeners_remove(struct master_service *service);
98 
99 void master_service_client_connection_handled(struct master_service *service,
100 					      struct master_service_connection *conn);
101 void master_service_client_connection_callback(struct master_service *service,
102 					       struct master_service_connection *conn);
103 
104 void master_service_haproxy_new(struct master_service *service,
105 				struct master_service_connection *conn);
106 void master_service_haproxy_abort(struct master_service *service);
107 
108 #endif
109