X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/ced0bbf43860a2e4ddc88e3ba20ae731324586c5..master:/src/src/daemon.c diff --git a/src/src/daemon.c b/src/src/daemon.c index aff05120a..16137f9f6 100644 --- a/src/src/daemon.c +++ b/src/src/daemon.c @@ -2,7 +2,7 @@ * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) The Exim Maintainers 2020 - 2023 */ +/* Copyright (c) The Exim Maintainers 2020 - 2024 */ /* Copyright (c) University of Cambridge 1995 - 2018 */ /* See the file NOTICE for conditions of use and distribution. */ /* SPDX-License-Identifier: GPL-2.0-or-later */ @@ -298,9 +298,10 @@ to provide host-specific limits according to $sender_host address, but because this is in the daemon mainline, only fast expansions (such as inline address checks) should be used. The documentation is full of warnings. */ +GET_OPTION("smtp_accept_max_per_host"); if (smtp_accept_max_per_host) { - uschar *expanded = expand_string(smtp_accept_max_per_host); + uschar * expanded = expand_string(smtp_accept_max_per_host); if (!expanded) { if (!f.expand_string_forcedfail) @@ -310,7 +311,7 @@ if (smtp_accept_max_per_host) /* For speed, interpret a decimal number inline here */ else { - uschar *s = expanded; + uschar * s = expanded; while (isdigit(*s)) max_for_this_host = max_for_this_host * 10 + *s++ - '0'; if (*s) @@ -319,9 +320,9 @@ if (smtp_accept_max_per_host) } } -/* If we have fewer connections than max_for_this_host, we can skip the tedious -per host_address checks. Note that at this stage smtp_accept_count contains the -count of *other* connections, not including this one. */ +/* If we have fewer total connections than max_for_this_host, we can skip the +tedious per host_address checks. Note that at this stage smtp_accept_count +contains the count of *other* connections, not including this one. */ if (max_for_this_host > 0 && smtp_accept_count >= max_for_this_host) { @@ -434,6 +435,7 @@ if (pid == 0) likely what it depends on.) */ smtp_active_hostname = primary_hostname; + GET_OPTION("smtp_active_hostname"); if (raw_active_hostname) { uschar * nah = expand_string(raw_active_hostname); @@ -918,7 +920,7 @@ while ((pid = waitpid(-1, &status, WNOHANG)) > 0) smtp_slots[i] = empty_smtp_slot; if (--smtp_accept_count < 0) smtp_accept_count = 0; DEBUG(D_any) debug_printf("%d SMTP accept process%s now running\n", - smtp_accept_count, (smtp_accept_count == 1)? "" : "es"); + smtp_accept_count, smtp_accept_count == 1 ? "" : "es"); break; } if (i < smtp_accept_max) continue; /* Found an accepting process */ @@ -1165,6 +1167,7 @@ return offsetof(struct sockaddr_un, sun_path) ssize_t daemon_notifier_sockname(struct sockaddr_un * sup) { +GET_OPTION("notifier_socket"); #ifdef EXIM_HAVE_ABSTRACT_UNIX_SOCKETS sup->sun_path[0] = 0; /* Abstract local socket addr - Linux-specific? */ return offsetof(struct sockaddr_un, sun_path) + 1 @@ -1490,7 +1493,7 @@ if (is_multiple_qrun()) /* we are managing periodic runs */ } else #endif - /* Normal periodic runL in order of run priority, find the first queue + /* Normal periodic run: in order of run priority, find the first queue for which we can start a runner */ for (q = qrunners; q; q = q->next) @@ -1654,7 +1657,7 @@ return 0; -const uschar * +static const uschar * describe_queue_runners(void) { gstring * g = NULL; @@ -1664,6 +1667,7 @@ if (!is_multiple_qrun()) return US"no queue runs"; for (qrunner * q = qrunners; q; q = q->next) { g = string_catn(g, US"-q", 2); + if (q->queue_2stage) g = string_catn(g, US"q", 1); if (q->name) g = string_append(g, 3, US"G", q->name, US"/"); g = string_cat(g, readconf_printtime(q->interval)); g = string_catn(g, US" ", 1); @@ -1708,12 +1712,13 @@ time_t last_connection_time = (time_t)0; int local_queue_run_max = 0; if (is_multiple_qrun()) - + { /* Nuber of runner-tracking structs needed: If the option queue_run_max has no expandable elements then it is the overall maximum; else we assume it depends on the queue name, and add them up to get the maximum. Evaluate both that and the individual limits. */ + GET_OPTION("queue_run_max"); if (Ustrchr(queue_run_max, '$') != NULL) { for (qrunner * q = qrunners; q; q = q->next) @@ -1730,6 +1735,7 @@ if (is_multiple_qrun()) for (qrunner * q = qrunners; q; q = q->next) q->run_max = local_queue_run_max; } + } process_purpose = US"daemon"; @@ -2151,7 +2157,7 @@ if (f.background_daemon) pid_t pid = exim_fork(US"daemon"); if (pid < 0) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "fork() failed when starting daemon: %s", strerror(errno)); - if (pid > 0) exit(EXIT_SUCCESS); /* in parent process, just exit */ + if (pid > 0) exim_exit(EXIT_SUCCESS); /* in parent process, just exit */ (void)setsid(); /* release controlling terminal */ f.daemon_listen = daemon_listen; }