8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen#ifndef MASTER_SERVICE_PRIVATE_H
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen#define MASTER_SERVICE_PRIVATE_H
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen#include "master-interface.h"
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen#include "master-service.h"
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8761992b5aa05862e7ec3a460cdc17af41a4a0f5Timo Sirainenstruct master_service_haproxy_conn;
8761992b5aa05862e7ec3a460cdc17af41a4a0f5Timo Sirainen
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainenstruct master_service_listener {
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen struct master_service *service;
71056e0f5e1f68cb9ac002a7827eb98435c40d62Timo Sirainen char *name;
71056e0f5e1f68cb9ac002a7827eb98435c40d62Timo Sirainen
71056e0f5e1f68cb9ac002a7827eb98435c40d62Timo Sirainen /* settings */
7487ff578435377bbeefffdbfb78ca09ed1292dfTimo Sirainen bool ssl;
8761992b5aa05862e7ec3a460cdc17af41a4a0f5Timo Sirainen bool haproxy;
71056e0f5e1f68cb9ac002a7827eb98435c40d62Timo Sirainen
71056e0f5e1f68cb9ac002a7827eb98435c40d62Timo Sirainen /* state */
04a6e51325d52a8f6046389406b2f606159a61e3Timo Sirainen bool closed;
71056e0f5e1f68cb9ac002a7827eb98435c40d62Timo Sirainen int fd;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen struct io *io;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen};
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenstruct master_service {
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen struct ioloop *ioloop;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen char *name;
578ef2538ccf42e2a48234c24a8b709397101d88Timo Sirainen char *getopt_str;
578ef2538ccf42e2a48234c24a8b709397101d88Timo Sirainen enum master_service_flags flags;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen int argc;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen char **argv;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen const char *version_string;
96d19229e5f322411eb84446e5477d8170cfa5afTimo Sirainen char *config_path;
d39a04db2f4d0599cb9b5f03a9aa10a3c234453cTimo Sirainen ARRAY_TYPE(const_string) config_overrides;
01230de017cd273de41143d88e9c18df1243ae8aTimo Sirainen int config_fd;
01230de017cd273de41143d88e9c18df1243ae8aTimo Sirainen int syslog_facility;
28bf8f762fcd21c57bf71822cf818447babce9a0Timo Sirainen data_stack_frame_t datastack_frame_id;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
f7423cbbd9dea363a5df18ebb96da055a977ae79Timo Sirainen struct master_service_listener *listeners;
71056e0f5e1f68cb9ac002a7827eb98435c40d62Timo Sirainen unsigned int socket_count;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen struct io *io_status_write, *io_status_error;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen unsigned int service_count_left;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen unsigned int total_available_count;
1ffb2afe6d7e8860a2231a4827078cf2ef9c22cdTimo Sirainen unsigned int process_limit;
d4845c4245638fd6f02dc0cb92c3465fae763cbbTimo Sirainen unsigned int process_min_avail;
0161376aac025266d8654577c4b9ce371ffc87eaTimo Sirainen unsigned int idle_kill_secs;
2037c54ef0239bf7814badab08fc15f945f560fbTimo Sirainen
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen struct master_status master_status;
2037c54ef0239bf7814badab08fc15f945f560fbTimo Sirainen unsigned int last_sent_status_avail_count;
2037c54ef0239bf7814badab08fc15f945f560fbTimo Sirainen time_t last_sent_status_time;
2037c54ef0239bf7814badab08fc15f945f560fbTimo Sirainen struct timeout *to_status;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen
ccf50662cc02b5e703039a4ff7f91a4470e25b71Timo Sirainen bool (*idle_die_callback)(void);
86791365b10f45982c88e70f2eb94fd6c3fea151Timo Sirainen void (*die_callback)(void);
86791365b10f45982c88e70f2eb94fd6c3fea151Timo Sirainen struct timeout *to_die;
86791365b10f45982c88e70f2eb94fd6c3fea151Timo Sirainen
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen void (*avail_overflow_callback)(void);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen struct timeout *to_overflow_state;
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen
7891c8e6debdcfec552cb1beea2a0230fe89957bTimo Sirainen struct master_login *login;
7891c8e6debdcfec552cb1beea2a0230fe89957bTimo Sirainen
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen master_service_connection_callback_t *callback;
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen pool_t set_pool;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen const struct master_service_settings *set;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen struct setting_parser_context *set_parser;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
f29756821a4c6b12b73e4a2a3e1c230117a43773Timo Sirainen struct ssl_iostream_context *ssl_ctx;
f29756821a4c6b12b73e4a2a3e1c230117a43773Timo Sirainen time_t ssl_params_last_refresh;
f29756821a4c6b12b73e4a2a3e1c230117a43773Timo Sirainen
b63e20ea9bc84f1aa90a551f217d01385e070b73Timo Sirainen struct stats_client *stats_client;
8761992b5aa05862e7ec3a460cdc17af41a4a0f5Timo Sirainen struct master_service_haproxy_conn *haproxy_conns;
8761992b5aa05862e7ec3a460cdc17af41a4a0f5Timo Sirainen
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool killed:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool stopping:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool keep_environment:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool log_directly:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool initial_status_sent:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool die_with_master:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool call_avail_overflow:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool config_path_changed_with_param:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool want_ssl_settings:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool ssl_ctx_initialized:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool config_path_from_master:1;
719abeb2088987f213a33a7dd1fe78958beaef03Timo Sirainen bool log_initialized:1;
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen};
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainenvoid master_service_io_listeners_add(struct master_service *service);
3ba9a079592f46e94ce846e5aa80e4d479cd5e41Timo Sirainenvoid master_status_update(struct master_service *service);
3ba9a079592f46e94ce846e5aa80e4d479cd5e41Timo Sirainenvoid master_service_close_config_fd(struct master_service *service);
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen
442232f2d1cfdf28f3a18aa00a5c19246d321036Timo Sirainenvoid master_service_io_listeners_remove(struct master_service *service);
f29756821a4c6b12b73e4a2a3e1c230117a43773Timo Sirainenvoid master_service_ssl_io_listeners_remove(struct master_service *service);
442232f2d1cfdf28f3a18aa00a5c19246d321036Timo Sirainen
8ab32a83ca0ead65c5670f337ca3a4d7a0fd0ed1Timo Sirainenvoid master_service_client_connection_handled(struct master_service *service,
8ab32a83ca0ead65c5670f337ca3a4d7a0fd0ed1Timo Sirainen struct master_service_connection *conn);
8ab32a83ca0ead65c5670f337ca3a4d7a0fd0ed1Timo Sirainenvoid master_service_client_connection_callback(struct master_service *service,
8ab32a83ca0ead65c5670f337ca3a4d7a0fd0ed1Timo Sirainen struct master_service_connection *conn);
8ab32a83ca0ead65c5670f337ca3a4d7a0fd0ed1Timo Sirainen
8761992b5aa05862e7ec3a460cdc17af41a4a0f5Timo Sirainenvoid master_service_haproxy_new(struct master_service *service,
8761992b5aa05862e7ec3a460cdc17af41a4a0f5Timo Sirainen struct master_service_connection *conn);
8761992b5aa05862e7ec3a460cdc17af41a4a0f5Timo Sirainenvoid master_service_haproxy_abort(struct master_service *service);
8761992b5aa05862e7ec3a460cdc17af41a4a0f5Timo Sirainen
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen#endif