#define WORKER_STATE_IDLE "idling"
#define WORKER_STATE_STOP "waiting for shutdown"
-static unsigned int auth_worker_max_service_count = 0;
-static unsigned int auth_worker_service_count = 0;
+static unsigned int auth_worker_max_restart_request_count = 0;
+static unsigned int auth_worker_restart_request_count = 0;
struct auth_worker_server {
struct connection conn;
static void auth_worker_server_destroy(struct connection *conn);
static void auth_worker_server_unref(struct auth_worker_server **_client);
-void auth_worker_set_max_service_count(unsigned int count)
+void auth_worker_set_max_restart_request_count(unsigned int count)
{
- auth_worker_max_service_count = count;
+ auth_worker_max_restart_request_count = count;
}
static struct auth_worker_server *auth_worker_get_client(void)
server->refcount++;
e_debug(cmd->event, "Handling %s request", args[1]);
- /* Check if we have reached service_count */
- if (auth_worker_max_service_count > 0) {
- auth_worker_service_count++;
- if (auth_worker_service_count >= auth_worker_max_service_count)
+ /* Check if we have reached restart_request_count */
+ if (auth_worker_max_restart_request_count > 0) {
+ auth_worker_restart_request_count++;
+ if (auth_worker_restart_request_count >= auth_worker_max_restart_request_count)
worker_restart_request = TRUE;
}
void auth_worker_connections_destroy_all(void);
/* Stop master service after this many requests. 0 is unlimited. */
-void auth_worker_set_max_service_count(unsigned int count);
+void auth_worker_set_max_restart_request_count(unsigned int count);
#endif
/* workers have only a single connection from the master
auth process */
master_service_set_client_limit(master_service, 1);
- auth_worker_set_max_service_count(
- master_service_get_service_count(master_service));
+ auth_worker_set_max_restart_request_count(
+ master_service_get_restart_request_count(master_service));
/* make sure this process cycles if auth connection drops */
- master_service_set_service_count(master_service, 1);
+ master_service_set_restart_request_count(master_service, 1);
} else {
/* caching is handled only by the main auth process */
passdb_cache_init(global_auth_settings);
.drop_priv_before_exec = FALSE,
.client_limit = 1,
- .service_count = 1,
+ .restart_request_count = 1,
.unix_listeners = ARRAY_INIT,
.fifo_listeners = ARRAY_INIT,
.drop_priv_before_exec = FALSE,
- .service_count = 1,
+ .restart_request_count = 1,
.unix_listeners = ARRAY_INIT,
.fifo_listeners = ARRAY_INIT,
.drop_priv_before_exec = FALSE,
- .service_count = 1,
+ .restart_request_count = 1,
.unix_listeners = ARRAY_INIT,
.fifo_listeners = ARRAY_INIT,
.process_limit = 1024,
.client_limit = 1,
- .service_count = 1,
+ .restart_request_count = 1,
.unix_listeners = ARRAY_INIT,
.fifo_listeners = ARRAY_INIT,
.process_limit = 1024,
.client_limit = 1,
- .service_count = 1,
+ .restart_request_count = 1,
.unix_listeners = ARRAY_INIT,
.fifo_listeners = ARRAY_INIT,
.process_limit = 1024,
.client_limit = 1,
- .service_count = 1,
+ .restart_request_count = 1,
.unix_listeners = ARRAY_INIT,
.fifo_listeners = ARRAY_INIT,
bool close_sockets;
close_sockets = service->master_status.available_count == 0 &&
- service->service_count_left == 1;
+ service->restart_request_count_left == 1;
request->conn->login_success = TRUE;
server->callback(request, auth_args[0], auth_args+1);
unsigned int socket_count;
struct io *io_status_write, *io_status_error;
- unsigned int service_count_left;
+ unsigned int restart_request_count_left;
unsigned int total_available_count;
unsigned int process_limit;
unsigned int process_min_avail;
i_strconcat(getopt_str, master_service_getopt_string(), NULL);
service->flags = flags;
service->ioloop = io_loop_create();
- service->service_count_left = UINT_MAX;
+ service->restart_request_count_left = UINT_MAX;
service->datastack_frame_id = datastack_frame_id;
service->config_path = i_strdup(getenv(MASTER_CONFIG_FILE_SOCKET_ENV));
value = getenv(MASTER_SERVICE_COUNT_ENV);
if (value != NULL && str_to_uint(value, &count) == 0 &&
count > 0)
- master_service_set_service_count(service, count);
+ master_service_set_restart_request_count(service, count);
/* set the idle kill timeout */
value = getenv(MASTER_SERVICE_IDLE_KILL_ENV);
service->idle_kill_secs = count;
} else {
master_service_set_client_limit(service, 1);
- master_service_set_service_count(service, 1);
+ master_service_set_restart_request_count(service, 1);
}
if ((flags & MASTER_SERVICE_FLAG_DONT_SEND_STATS) == 0) {
/* Initialize stats-client early so it can see all events. */
return service->idle_kill_secs;
}
-void master_service_set_service_count(struct master_service *service,
- unsigned int count)
+void master_service_set_restart_request_count(struct master_service *service,
+ unsigned int count)
{
unsigned int used;
service->total_available_count = count;
service->master_status.available_count = count - used;
}
- service->service_count_left = count;
+ service->restart_request_count_left = count;
}
-unsigned int master_service_get_service_count(struct master_service *service)
+unsigned int master_service_get_restart_request_count(struct master_service *service)
{
- return service->service_count_left;
+ return service->restart_request_count_left;
}
unsigned int master_service_get_socket_count(struct master_service *service)
/* make sure we stop after servicing current connections */
current_count = service->total_available_count -
service->master_status.available_count;
- service->service_count_left = current_count;
+ service->restart_request_count_left = current_count;
service->total_available_count = current_count;
if (current_count == 0)
/* more concurrent clients can still be added */
return TRUE;
}
- if (service->service_count_left == 1) {
+ if (service->restart_request_count_left == 1) {
/* after handling this client, the whole process will stop. */
return FALSE;
}
if (!master_service_want_listener(service)) {
i_assert(service->listeners != NULL);
master_service_io_listeners_remove(service);
- if (service->service_count_left == 1 &&
+ if (service->restart_request_count_left == 1 &&
service->avail_overflow_callback == NULL) {
/* we're not going to accept any more connections after
this. go ahead and close the connection early. don't
permissions).
Don't do this if overflow callback is set, because
- otherwise it's never called with service_count=1.
- Actually this isn't important anymore to do with
- any service, since nowadays master can request the
- listeners to be closed via SIGQUIT. Still, closing
- the fd when possible saves a little bit of memory. */
+ otherwise it's never called with
+ restart_request_count=1. Actually this isn't
+ important anymore to do with any service, since
+ nowadays master can request the listeners to be
+ closed via SIGQUIT. Still, closing the fd when
+ possible saves a little bit of memory. */
master_service_io_listeners_close(service);
}
}
master_service_io_listeners_add(service);
i_assert(service->total_available_count > 0);
- i_assert(service->service_count_left > 0);
+ i_assert(service->restart_request_count_left > 0);
- if (service->service_count_left == service->total_available_count) {
+ if (service->restart_request_count_left == service->total_available_count) {
service->total_available_count--;
- service->service_count_left--;
+ service->restart_request_count_left--;
} else {
- if (service->service_count_left != UINT_MAX)
- service->service_count_left--;
+ if (service->restart_request_count_left != UINT_MAX)
+ service->restart_request_count_left--;
i_assert(service->master_status.available_count <
service->total_available_count);
service->master_status.available_count++;
}
- if (service->service_count_left == 0) {
+ if (service->restart_request_count_left == 0) {
i_assert(service->master_status.available_count ==
service->total_available_count);
master_service_stop(service);
return;
}
if (service->master_status.available_count == 0) {
- /* Client was destroyed, but service_count is now 0.
+ /* Client was destroyed, but restart_request_count is now 0.
The servive was already stopped, so the process will
shutdown and a new process can handle the waiting client
connection. */
- i_assert(service->service_count_left == 0);
+ i_assert(service->restart_request_count_left == 0);
i_assert(!io_loop_is_running(service->ioloop));
return;
}
}
/* This process can't create more than a single client. Most likely
- running with service_count=1. Check the overflow again after a short
- delay before killing anything. This way only some of the connections
- get killed instead of all of them. The delay is based on the
- connection age with a bit of randomness, so the oldest connections
- should die first, but even if all the connections have time same
- timestamp they still don't all die at once. */
+ running with restart_request_count=1. Check the overflow again after
+ a short delay before killing anything. This way only some of the
+ connections get killed instead of all of them. The delay is based on
+ the connection age with a bit of randomness, so the oldest
+ connections should die first, but even if all the connections have
+ time same timestamp they still don't all die at once. */
if (!service->avail_overflow_callback(FALSE, &created)) {
/* can't kill any clients */
return TRUE;
/* Set maximum number of client connections we will handle before shutting
down. */
-void master_service_set_service_count(struct master_service *service,
- unsigned int count);
+void master_service_set_restart_request_count(struct master_service *service,
+ unsigned int count);
/* Returns the number of client connections we will handle before shutting
down. The value is decreased only after connection has been closed. */
-unsigned int master_service_get_service_count(struct master_service *service);
+unsigned int master_service_get_restart_request_count(struct master_service *service);
/* Return the number of listener sockets. */
unsigned int master_service_get_socket_count(struct master_service *service);
/* Returns the name of the listener socket, or "" if none is specified. */
unsigned int process_min_avail;
unsigned int process_limit;
unsigned int client_limit;
- unsigned int service_count;
+ unsigned int restart_request_count;
unsigned int idle_kill;
uoff_t vsz_limit;
login_proxy_free(&client->login_proxy);
if (client->v.destroy != NULL)
client->v.destroy(client);
- if (client_unref(&client) && initial_service_count == 1) {
+ if (client_unref(&client) && initial_restart_request_count == 1) {
/* as soon as this connection is done with proxying
(or whatever), the process will die. there's no need for
authentication anymore, so close the connection.
- do this only with initial service_count=1, in case there
- are other clients with pending authentications */
+ do this only with initial restart_request_count=1, in case
+ there are other clients with pending authentications */
auth_client_disconnect(auth_client, "unnecessary connection");
}
login_client_destroyed();
extern bool closing_down, login_debug;
extern struct anvil_client *anvil;
extern const char *login_rawlog_dir;
-extern unsigned int initial_service_count;
+extern unsigned int initial_restart_request_count;
/* NULL-terminated array of all alt_usernames seen so far. Existing fields are
never removed. */
extern ARRAY_TYPE(string) global_alt_usernames;
bool closing_down, login_debug;
struct anvil_client *anvil;
const char *login_rawlog_dir = NULL;
-unsigned int initial_service_count;
+unsigned int initial_restart_request_count;
struct login_module_register login_module_register;
ARRAY_TYPE(string) global_alt_usernames;
bool login_ssl_initialized;
/etc/hosts */
parse_login_source_ips(global_login_settings->login_source_ips);
if (login_source_v4_ips_count > 0) {
- /* randomize the initial index in case service_count=1
+ /* randomize the initial index in case restart_service_count=1
(although in that case it's unlikely this setting is
even used..) */
login_source_v4_ips_idx = i_rand_limit(login_source_v4_ips_count);
restrict_access_by_env(0, NULL);
if (login_debug)
restrict_access_allow_coredumps(TRUE);
- initial_service_count = master_service_get_service_count(master_service);
+ initial_restart_request_count = master_service_get_restart_request_count(master_service);
if (restrict_access_get_current_chroot() == NULL) {
if (chdir("login") < 0)
DEF(UINT, process_min_avail),
DEF(UINT, process_limit),
DEF(UINT, client_limit),
- DEF(UINT, service_count),
+ DEF(UINT, restart_request_count),
DEF(TIME, idle_kill),
DEF(SIZE, vsz_limit),
.process_min_avail = 0,
.process_limit = 100,
.client_limit = 1000,
- .service_count = 0,
+ .restart_request_count = 0,
.idle_kill = 60,
.vsz_limit = 256*1024*1024,
if (*service->protocol != '\0') {
/* each imap/pop3/lmtp process can use up a connection,
- although if service_count=1 it's only temporary.
+ although if restart_request_count=1 it's only temporary.
imap-hibernate doesn't do any auth lookups. */
- if ((service->service_count != 1 ||
+ if ((service->restart_request_count != 1 ||
strcmp(service->type, "login") == 0) &&
strcmp(service->name, "imap-hibernate") != 0) {
str_printfa(max_auth_client_processes_reason,
str_delete(max_auth_client_processes_reason, 0, 3);
i_warning("service auth { client_limit=%u } is lower than "
"required under max. load (%u). "
- "Counted for protocol services with service_count != 1: %s",
+ "Counted for protocol services with restart_request_count != 1: %s",
client_limit, max_auth_client_processes,
str_c(max_auth_client_processes_reason));
}
(It's actually not important which processes get killed. A better
way could be to kill the oldest processes since they might have to
- be restarted anyway soon due to reaching service_count, but we'd
- have to use priority queue for tracking that, which is more
+ be restarted anyway soon due to reaching restart_request_count, but
+ we'd have to use priority queue for tracking that, which is more
expensive and probably not worth it.) */
for (; processes_to_kill > 0; processes_to_kill--) {
struct service_process *process = service->idle_processes_head;
if (service->process_limit > 1) {
limit_name = "process_limit";
limit = service->process_limit;
- } else if (service->set->service_count == 1) {
+ } else if (service->set->restart_request_count == 1) {
i_assert(service->client_limit == 1);
- limit_name = "client_limit/service_count";
+ limit_name = "client_limit/restart_request_count";
limit = 1;
} else {
limit_name = "client_limit";
env_put(MASTER_PROCESS_MIN_AVAIL_ENV,
dec2str(service->set->process_min_avail));
env_put(MASTER_SERVICE_IDLE_KILL_ENV, dec2str(service->idle_kill));
- if (service->set->service_count != 0) {
+ if (service->set->restart_request_count != 0) {
env_put(MASTER_SERVICE_COUNT_ENV,
- dec2str(service->set->service_count));
+ dec2str(service->set->restart_request_count));
}
env_put(MASTER_UID_ENV, dec2str(uid));
env_put(MY_HOSTNAME_ENV, my_hostname);
service->throttle_msecs = SERVICE_STARTUP_FAILURE_THROTTLE_MIN_MSECS;
service->client_limit = set->client_limit;
- if (set->service_count > 0 &&
- service->client_limit > set->service_count)
- service->client_limit = set->service_count;
+ if (set->restart_request_count > 0 &&
+ service->client_limit > set->restart_request_count)
+ service->client_limit = set->restart_request_count;
service->vsz_limit = set->vsz_limit;
service->idle_kill = set->idle_kill;
.drop_priv_before_exec = FALSE,
- .service_count = 1,
+ .restart_request_count = 1,
.unix_listeners = ARRAY_INIT,
.fifo_listeners = ARRAY_INIT,
.process_limit = 1024,
.client_limit = 1,
- .service_count = 1,
+ .restart_request_count = 1,
.unix_listeners = ARRAY_INIT,
.fifo_listeners = ARRAY_INIT,
struct master_service local_master_service = {
.stopping = TRUE,
.total_available_count = 100,
- .service_count_left = 100,
+ .restart_request_count_left = 100,
};
void (*const test_functions[])(void) = {
test_client_reader,
struct master_service local_master_service = {
.stopping = TRUE,
.total_available_count = 100,
- .service_count_left = 100,
+ .restart_request_count_left = 100,
};
void (*const test_functions[])(void) = {
test_client_writer,
.drop_priv_before_exec = FALSE,
- .service_count = 1,
+ .restart_request_count = 1,
.unix_listeners = ARRAY_INIT,
.fifo_listeners = ARRAY_INIT,
.process_limit = 1024,
.client_limit = 1,
- .service_count = 1,
+ .restart_request_count = 1,
.unix_listeners = ARRAY_INIT,
.fifo_listeners = ARRAY_INIT,
}
master_service_init_finish(master_service);
- master_service_set_service_count(master_service, 1);
+ master_service_set_restart_request_count(master_service, 1);
if ((flags & MASTER_SERVICE_FLAG_STANDALONE) != 0) {
/* The last post-login script is calling us to finish login */
restrict_access_allow_coredumps(TRUE);
master_service_init_finish(master_service);
- master_service_set_service_count(master_service, 1);
+ master_service_set_restart_request_count(master_service, 1);
if (argv[0][0] == '/')
binary = argv[0];