7 /* Postfix queue manager
9 /* \fBqmgr\fR [generic Postfix daemon options]
11 /* The \fBqmgr\fR(8) daemon awaits the arrival of incoming mail
12 /* and arranges for its delivery via Postfix delivery processes.
13 /* The actual mail routing strategy is delegated to the
14 /* \fBtrivial-rewrite\fR(8) daemon.
15 /* This program expects to be run from the \fBmaster\fR(8) process
18 /* Mail addressed to the local \fBdouble-bounce\fR address is
19 /* logged and discarded. This stops potential loops caused by
20 /* undeliverable bounce notifications.
24 /* The \fBqmgr\fR(8) daemon maintains the following queues:
26 /* Inbound mail from the network, or mail picked up by the
27 /* local \fBpickup\fR(8) daemon from the \fBmaildrop\fR directory.
29 /* Messages that the queue manager has opened for delivery. Only
30 /* a limited number of messages is allowed to enter the \fBactive\fR
31 /* queue (leaky bucket strategy, for a fixed delivery rate).
33 /* Mail that could not be delivered upon the first attempt. The queue
34 /* manager implements exponential backoff by doubling the time between
37 /* Unreadable or damaged queue files are moved here for inspection.
39 /* Messages that are kept "on hold" are kept here until someone
41 /* DELIVERY STATUS REPORTS
44 /* The \fBqmgr\fR(8) daemon keeps an eye on per-message delivery status
45 /* reports in the following directories. Each status report file has
46 /* the same name as the corresponding message file:
48 /* Per-recipient status information about why mail is bounced.
49 /* These files are maintained by the \fBbounce\fR(8) daemon.
51 /* Per-recipient status information about why mail is delayed.
52 /* These files are maintained by the \fBdefer\fR(8) daemon.
54 /* Per-recipient status information as requested with the
55 /* Postfix "\fBsendmail -v\fR" or "\fBsendmail -bv\fR" command.
56 /* These files are maintained by the \fBtrace\fR(8) daemon.
58 /* The \fBqmgr\fR(8) daemon is responsible for asking the
59 /* \fBbounce\fR(8), \fBdefer\fR(8) or \fBtrace\fR(8) daemons to
60 /* send delivery reports.
64 /* The queue manager implements a variety of strategies for
65 /* either opening queue files (input) or for message delivery (output).
66 /* .IP "\fBleaky bucket\fR"
67 /* This strategy limits the number of messages in the \fBactive\fR queue
68 /* and prevents the queue manager from running out of memory under
71 /* When the \fBactive\fR queue has room, the queue manager takes one
72 /* message from the \fBincoming\fR queue and one from the \fBdeferred\fR
73 /* queue. This prevents a large mail backlog from blocking the delivery
75 /* .IP "\fBslow start\fR"
76 /* This strategy eliminates "thundering herd" problems by slowly
77 /* adjusting the number of parallel deliveries to the same destination.
78 /* .IP "\fBround robin\fR
79 /* The queue manager sorts delivery requests by destination.
80 /* Round-robin selection prevents one destination from dominating
81 /* deliveries to other destinations.
82 /* .IP "\fBexponential backoff\fR"
83 /* Mail that cannot be delivered upon the first attempt is deferred.
84 /* The time interval between delivery attempts is doubled after each
86 /* .IP "\fBdestination status cache\fR"
87 /* The queue manager avoids unnecessary delivery attempts by
88 /* maintaining a short-term, in-memory list of unreachable destinations.
89 /* .IP "\fBpreemptive message scheduling\fR"
90 /* The queue manager attempts to minimize the average per-recipient delay
91 /* while still preserving the correct per-message delays, using
92 /* a sophisticated preemptive message scheduling.
96 /* On an idle system, the queue manager waits for the arrival of
97 /* trigger events, or it waits for a timer to go off. A trigger
98 /* is a one-byte message.
99 /* Depending on the message received, the queue manager performs
100 /* one of the following actions (the message is followed by the
101 /* symbolic constant used internally by the software):
102 /* .IP "\fBD (QMGR_REQ_SCAN_DEFERRED)\fR"
103 /* Start a deferred queue scan. If a deferred queue scan is already
104 /* in progress, that scan will be restarted as soon as it finishes.
105 /* .IP "\fBI (QMGR_REQ_SCAN_INCOMING)\fR"
106 /* Start an incoming queue scan. If an incoming queue scan is already
107 /* in progress, that scan will be restarted as soon as it finishes.
108 /* .IP "\fBA (QMGR_REQ_SCAN_ALL)\fR"
109 /* Ignore deferred queue file time stamps. The request affects
110 /* the next deferred queue scan.
111 /* .IP "\fBF (QMGR_REQ_FLUSH_DEAD)\fR"
112 /* Purge all information about dead transports and destinations.
113 /* .IP "\fBW (TRIGGER_REQ_WAKEUP)\fR"
114 /* Wakeup call, This is used by the master server to instantiate
115 /* servers that should not go away forever. The action is to start
116 /* an incoming queue scan.
118 /* The \fBqmgr\fR(8) daemon reads an entire buffer worth of triggers.
119 /* Multiple identical trigger requests are collapsed into one, and
120 /* trigger requests are sorted so that \fBA\fR and \fBF\fR precede
121 /* \fBD\fR and \fBI\fR. Thus, in order to force a deferred queue run,
122 /* one would request \fBA F D\fR; in order to notify the queue manager
123 /* of the arrival of new mail one would request \fBI\fR.
125 /* RFC 3463 (Enhanced status codes)
126 /* RFC 3464 (Delivery status notifications)
130 /* The \fBqmgr\fR(8) daemon is not security sensitive. It reads
131 /* single-character messages from untrusted local users, and thus may
132 /* be susceptible to denial of service attacks. The \fBqmgr\fR(8) daemon
133 /* does not talk to the outside world, and it can be run at fixed low
134 /* privilege in a chrooted environment.
136 /* Problems and transactions are logged to the syslog daemon.
137 /* Corrupted message files are saved to the \fBcorrupt\fR queue
138 /* for further inspection.
140 /* Depending on the setting of the \fBnotify_classes\fR parameter,
141 /* the postmaster is notified of bounces and of other trouble.
143 /* A single queue manager process has to compete for disk access with
144 /* multiple front-end processes such as \fBcleanup\fR(8). A sudden burst of
145 /* inbound mail can negatively impact outbound delivery rates.
146 /* CONFIGURATION PARAMETERS
149 /* Changes to \fBmain.cf\fR are not picked up automatically
151 /* is a persistent process. Use the "\fBpostfix reload\fR" command after
152 /* a configuration change.
154 /* The text below provides only a parameter summary. See
155 /* \fBpostconf\fR(5) for more details including examples.
157 /* In the text below, \fItransport\fR is the first field in a
158 /* \fBmaster.cf\fR entry.
159 /* COMPATIBILITY CONTROLS
162 /* Available before Postfix version 2.5:
163 /* .IP "\fBallow_min_user (no)\fR"
164 /* Allow a sender or recipient address to have `-' as the first
166 /* ACTIVE QUEUE CONTROLS
169 /* .IP "\fBqmgr_clog_warn_time (300s)\fR"
170 /* The minimal delay between warnings that a specific destination is
171 /* clogging up the Postfix active queue.
172 /* .IP "\fBqmgr_message_active_limit (20000)\fR"
173 /* The maximal number of messages in the active queue.
174 /* .IP "\fBqmgr_message_recipient_limit (20000)\fR"
175 /* The maximal number of recipients held in memory by the Postfix
176 /* queue manager, and the maximal size of the size of the short-term,
177 /* in-memory "dead" destination status cache.
178 /* .IP "\fBqmgr_message_recipient_minimum (10)\fR"
179 /* The minimal number of in-memory recipients for any message.
180 /* .IP "\fBdefault_recipient_limit (20000)\fR"
181 /* The default per-transport upper limit on the number of in-memory
183 /* .IP "\fItransport\fB_recipient_limit ($default_recipient_limit)\fR"
184 /* Idem, for delivery via the named message \fItransport\fR.
185 /* .IP "\fBdefault_extra_recipient_limit (1000)\fR"
186 /* The default value for the extra per-transport limit imposed on the
187 /* number of in-memory recipients.
188 /* .IP "\fItransport\fB_extra_recipient_limit ($default_extra_recipient_limit)\fR"
189 /* Idem, for delivery via the named message \fItransport\fR.
191 /* Available in Postfix version 2.4 and later:
192 /* .IP "\fBdefault_recipient_refill_limit (100)\fR"
193 /* The default per-transport limit on the number of recipients refilled at
195 /* .IP "\fItransport\fB_recipient_refill_limit ($default_recipient_refill_limit)\fR"
196 /* Idem, for delivery via the named message \fItransport\fR.
197 /* .IP "\fBdefault_recipient_refill_delay (5s)\fR"
198 /* The default per-transport maximum delay between recipients refills.
199 /* .IP "\fItransport\fB_recipient_refill_delay ($default_recipient_refill_delay)\fR"
200 /* Idem, for delivery via the named message \fItransport\fR.
201 /* DELIVERY CONCURRENCY CONTROLS
204 /* .IP "\fBinitial_destination_concurrency (5)\fR"
205 /* The initial per-destination concurrency level for parallel delivery
206 /* to the same destination.
207 /* .IP "\fBdefault_destination_concurrency_limit (20)\fR"
208 /* The default maximal number of parallel deliveries to the same
210 /* .IP "\fItransport\fB_destination_concurrency_limit ($default_destination_concurrency_limit)\fR"
211 /* Idem, for delivery via the named message \fItransport\fR.
213 /* Available in Postfix version 2.5 and later:
214 /* .IP "\fItransport\fB_initial_destination_concurrency ($initial_destination_concurrency)\fR"
215 /* Initial concurrency for delivery via the named message
217 /* .IP "\fBdefault_destination_concurrency_failed_cohort_limit (1)\fR"
218 /* How many pseudo-cohorts must suffer connection or handshake
219 /* failure before a specific destination is considered unavailable
220 /* (and further delivery is suspended).
221 /* .IP "\fItransport\fB_destination_concurrency_failed_cohort_limit ($default_destination_concurrency_failed_cohort_limit)\fR"
222 /* Idem, for delivery via the named message \fItransport\fR.
223 /* .IP "\fBdefault_destination_concurrency_negative_feedback (1)\fR"
224 /* The per-destination amount of delivery concurrency negative
225 /* feedback, after a delivery completes with a connection or handshake
227 /* .IP "\fItransport\fB_destination_concurrency_negative_feedback ($default_destination_concurrency_negative_feedback)\fR"
228 /* Idem, for delivery via the named message \fItransport\fR.
229 /* .IP "\fBdefault_destination_concurrency_positive_feedback (1)\fR"
230 /* The per-destination amount of delivery concurrency positive
231 /* feedback, after a delivery completes without connection or handshake
233 /* .IP "\fItransport\fB_destination_concurrency_positive_feedback ($default_destination_concurrency_positive_feedback)\fR"
234 /* Idem, for delivery via the named message \fItransport\fR.
235 /* .IP "\fBdestination_concurrency_feedback_debug (no)\fR"
236 /* Make the queue manager's feedback algorithm verbose for performance
237 /* analysis purposes.
238 /* RECIPIENT SCHEDULING CONTROLS
241 /* .IP "\fBdefault_destination_recipient_limit (50)\fR"
242 /* The default maximal number of recipients per message delivery.
243 /* .IP "\fItransport\fB_destination_recipient_limit ($default_destination_recipient_limit)\fR"
244 /* Idem, for delivery via the named message \fItransport\fR.
245 /* MESSAGE SCHEDULING CONTROLS
248 /* .IP "\fBdefault_delivery_slot_cost (5)\fR"
249 /* How often the Postfix queue manager's scheduler is allowed to
250 /* preempt delivery of one message with another.
251 /* .IP "\fItransport\fB_delivery_slot_cost ($default_delivery_slot_cost)\fR"
252 /* Idem, for delivery via the named message \fItransport\fR.
253 /* .IP "\fBdefault_minimum_delivery_slots (3)\fR"
254 /* How many recipients a message must have in order to invoke the
255 /* Postfix queue manager's scheduling algorithm at all.
256 /* .IP "\fItransport\fB_minimum_delivery_slots ($default_minimum_delivery_slots)\fR"
257 /* Idem, for delivery via the named message \fItransport\fR.
258 /* .IP "\fBdefault_delivery_slot_discount (50)\fR"
259 /* The default value for transport-specific _delivery_slot_discount
261 /* .IP "\fItransport\fB_delivery_slot_discount ($default_delivery_slot_discount)\fR"
262 /* Idem, for delivery via the named message \fItransport\fR.
263 /* .IP "\fBdefault_delivery_slot_loan (3)\fR"
264 /* The default value for transport-specific _delivery_slot_loan
266 /* .IP "\fItransport\fB_delivery_slot_loan ($default_delivery_slot_loan)\fR"
267 /* Idem, for delivery via the named message \fItransport\fR.
268 /* OTHER RESOURCE AND RATE CONTROLS
271 /* .IP "\fBminimal_backoff_time (300s)\fR"
272 /* The minimal time between attempts to deliver a deferred message;
273 /* prior to Postfix 2.4 the default value was 1000s.
274 /* .IP "\fBmaximal_backoff_time (4000s)\fR"
275 /* The maximal time between attempts to deliver a deferred message.
276 /* .IP "\fBmaximal_queue_lifetime (5d)\fR"
277 /* The maximal time a message is queued before it is sent back as
279 /* .IP "\fBqueue_run_delay (300s)\fR"
280 /* The time between deferred queue scans by the queue manager;
281 /* prior to Postfix 2.4 the default value was 1000s.
282 /* .IP "\fBtransport_retry_time (60s)\fR"
283 /* The time between attempts by the Postfix queue manager to contact
284 /* a malfunctioning message delivery transport.
286 /* Available in Postfix version 2.1 and later:
287 /* .IP "\fBbounce_queue_lifetime (5d)\fR"
288 /* The maximal time a bounce message is queued before it is considered
291 /* Available in Postfix version 2.5 and later:
292 /* .IP "\fBdefault_destination_rate_delay (0s)\fR"
293 /* The default amount of delay that is inserted between individual
294 /* deliveries to the same destination; with per-destination recipient
295 /* limit > 1, a destination is a domain, otherwise it is a recipient.
296 /* .IP "\fItransport\fB_destination_rate_delay $default_destination_rate_delay
297 /* Idem, for delivery via the named message \fItransport\fR.
298 /* MISCELLANEOUS CONTROLS
301 /* .IP "\fBconfig_directory (see 'postconf -d' output)\fR"
302 /* The default location of the Postfix main.cf and master.cf
303 /* configuration files.
304 /* .IP "\fBdefer_transports (empty)\fR"
305 /* The names of message delivery transports that should not deliver mail
306 /* unless someone issues "\fBsendmail -q\fR" or equivalent.
307 /* .IP "\fBdelay_logging_resolution_limit (2)\fR"
308 /* The maximal number of digits after the decimal point when logging
309 /* sub-second delay values.
310 /* .IP "\fBhelpful_warnings (yes)\fR"
311 /* Log warnings about problematic configuration settings, and provide
312 /* helpful suggestions.
313 /* .IP "\fBipc_timeout (3600s)\fR"
314 /* The time limit for sending or receiving information over an internal
315 /* communication channel.
316 /* .IP "\fBprocess_id (read-only)\fR"
317 /* The process ID of a Postfix command or daemon process.
318 /* .IP "\fBprocess_name (read-only)\fR"
319 /* The process name of a Postfix command or daemon process.
320 /* .IP "\fBqueue_directory (see 'postconf -d' output)\fR"
321 /* The location of the Postfix top-level queue directory.
322 /* .IP "\fBsyslog_facility (mail)\fR"
323 /* The syslog facility of Postfix logging.
324 /* .IP "\fBsyslog_name (see 'postconf -d' output)\fR"
325 /* The mail system name that is prepended to the process name in syslog
326 /* records, so that "smtpd" becomes, for example, "postfix/smtpd".
328 /* /var/spool/postfix/incoming, incoming queue
329 /* /var/spool/postfix/active, active queue
330 /* /var/spool/postfix/deferred, deferred queue
331 /* /var/spool/postfix/bounce, non-delivery status
332 /* /var/spool/postfix/defer, non-delivery status
333 /* /var/spool/postfix/trace, delivery status
335 /* trivial-rewrite(8), address routing
336 /* bounce(8), delivery status reports
337 /* postconf(5), configuration parameters
338 /* master(5), generic daemon options
339 /* master(8), process manager
340 /* syslogd(8), system logging
344 /* Use "\fBpostconf readme_directory\fR" or
345 /* "\fBpostconf html_directory\fR" to locate this information.
348 /* SCHEDULER_README, scheduling algorithm
349 /* QSHAPE_README, Postfix queue analysis
353 /* The Secure Mailer license must be distributed with this software.
356 /* IBM T.J. Watson Research
358 /* Yorktown Heights, NY 10598, USA
360 /* Preemptive scheduler enhancements:
363 /* 155 00, Prague, Czech Republic
366 /* System library. */
368 #include <sys_defs.h>
373 /* Utility library. */
380 /* Global library. */
382 #include <mail_queue.h>
383 #include <recipient_list.h>
384 #include <mail_conf.h>
385 #include <mail_params.h>
386 #include <mail_version.h>
387 #include <mail_proto.h> /* QMGR_SCAN constants */
388 #include <mail_flow.h>
389 #include <flush_clnt.h>
391 /* Master process interface */
393 #include <master_proto.h>
394 #include <mail_server.h>
396 /* Application-specific. */
403 int var_queue_run_delay
;
404 int var_min_backoff_time
;
405 int var_max_backoff_time
;
406 int var_max_queue_time
;
407 int var_dsn_queue_time
;
408 int var_qmgr_active_limit
;
409 int var_qmgr_rcpt_limit
;
410 int var_qmgr_msg_rcpt_limit
;
411 int var_xport_rcpt_limit
;
412 int var_stack_rcpt_limit
;
413 int var_xport_refill_limit
;
414 int var_xport_refill_delay
;
415 int var_delivery_slot_cost
;
416 int var_delivery_slot_loan
;
417 int var_delivery_slot_discount
;
418 int var_min_delivery_slots
;
419 int var_init_dest_concurrency
;
420 int var_transport_retry_time
;
421 int var_dest_con_limit
;
422 int var_dest_rcpt_limit
;
423 char *var_defer_xports
;
424 int var_local_con_lim
;
425 int var_local_rcpt_lim
;
427 bool var_verp_bounce_off
;
428 int var_qmgr_clog_warn_time
;
429 char *var_conc_pos_feedback
;
430 char *var_conc_neg_feedback
;
431 int var_conc_cohort_limit
;
432 int var_conc_feedback_debug
;
433 int var_dest_rate_delay
;
435 static QMGR_SCAN
*qmgr_scans
[2];
437 #define QMGR_SCAN_IDX_INCOMING 0
438 #define QMGR_SCAN_IDX_DEFERRED 1
439 #define QMGR_SCAN_IDX_COUNT (sizeof(qmgr_scans) / sizeof(qmgr_scans[0]))
441 /* qmgr_deferred_run_event - queue manager heartbeat */
443 static void qmgr_deferred_run_event(int unused_event
, char *dummy
)
447 * This routine runs when it is time for another deferred queue scan.
448 * Make sure this routine gets called again in the future.
450 qmgr_scan_request(qmgr_scans
[QMGR_SCAN_IDX_DEFERRED
], QMGR_SCAN_START
);
451 event_request_timer(qmgr_deferred_run_event
, dummy
, var_queue_run_delay
);
454 /* qmgr_trigger_event - respond to external trigger(s) */
456 static void qmgr_trigger_event(char *buf
, int len
,
457 char *unused_service
, char **argv
)
459 int incoming_flag
= 0;
460 int deferred_flag
= 0;
464 * Sanity check. This service takes no command-line arguments.
467 msg_fatal("unexpected command-line argument: %s", argv
[0]);
470 * Collapse identical requests that have arrived since we looked last
471 * time. There is no client feedback so there is no need to process each
472 * request in order. And as long as we don't have conflicting requests we
473 * are free to sort them into the most suitable order.
475 #define QMGR_FLUSH_BEFORE (QMGR_FLUSH_ONCE | QMGR_FLUSH_DFXP)
477 for (i
= 0; i
< len
; i
++) {
479 msg_info("request: %d (%c)",
480 buf
[i
], ISALNUM(buf
[i
]) ? buf
[i
] : '?');
482 case TRIGGER_REQ_WAKEUP
:
483 case QMGR_REQ_SCAN_INCOMING
:
484 incoming_flag
|= QMGR_SCAN_START
;
486 case QMGR_REQ_SCAN_DEFERRED
:
487 deferred_flag
|= QMGR_SCAN_START
;
489 case QMGR_REQ_FLUSH_DEAD
:
490 deferred_flag
|= QMGR_FLUSH_BEFORE
;
491 incoming_flag
|= QMGR_FLUSH_BEFORE
;
493 case QMGR_REQ_SCAN_ALL
:
494 deferred_flag
|= QMGR_SCAN_ALL
;
495 incoming_flag
|= QMGR_SCAN_ALL
;
499 msg_info("request ignored");
505 * Process each request type at most once. Modifiers take effect upon the
506 * next queue run. If no queue run is in progress, and a queue scan is
507 * requested, the request takes effect immediately.
509 if (incoming_flag
!= 0)
510 qmgr_scan_request(qmgr_scans
[QMGR_SCAN_IDX_INCOMING
], incoming_flag
);
511 if (deferred_flag
!= 0)
512 qmgr_scan_request(qmgr_scans
[QMGR_SCAN_IDX_DEFERRED
], deferred_flag
);
515 /* qmgr_loop - queue manager main loop */
517 static int qmgr_loop(char *unused_name
, char **unused_argv
)
522 int scan_idx
; /* Priority order scan index */
523 static int first_scan_idx
= QMGR_SCAN_IDX_INCOMING
;
524 int last_scan_idx
= QMGR_SCAN_IDX_COUNT
- 1;
528 * This routine runs as part of the event handling loop, after the event
529 * manager has delivered a timer or I/O event (including the completion
530 * of a connection to a delivery process), or after it has waited for a
531 * specified amount of time. The result value of qmgr_loop() specifies
532 * how long the event manager should wait for the next event.
535 #define WAIT_FOR_EVENT (-1)
538 * Attempt to drain the active queue by allocating a suitable delivery
539 * process and by delivering mail via it. Delivery process allocation and
540 * mail delivery are asynchronous.
545 * Let some new blood into the active queue when the queue size is
546 * smaller than some configurable limit.
548 * We import one message per interrupt, to optimally tune the input count
549 * for the number of delivery agent protocol wait states, as explained in
552 delay
= WAIT_FOR_EVENT
;
553 for (scan_idx
= 0; qmgr_message_count
< var_qmgr_active_limit
554 && scan_idx
< QMGR_SCAN_IDX_COUNT
; ++scan_idx
) {
555 last_scan_idx
= (scan_idx
+ first_scan_idx
) % QMGR_SCAN_IDX_COUNT
;
556 if ((path
= qmgr_scan_next(qmgr_scans
[last_scan_idx
])) != 0) {
558 if ((feed
= qmgr_active_feed(qmgr_scans
[last_scan_idx
], path
)) != 0)
564 * Round-robin the queue scans. When the active queue becomes full,
565 * prefer new mail over deferred mail.
567 if (qmgr_message_count
< var_qmgr_active_limit
) {
568 first_scan_idx
= (last_scan_idx
+ 1) % QMGR_SCAN_IDX_COUNT
;
569 } else if (first_scan_idx
!= QMGR_SCAN_IDX_INCOMING
) {
570 first_scan_idx
= QMGR_SCAN_IDX_INCOMING
;
574 * Global flow control. If enabled, slow down receiving processes that
575 * get ahead of the queue manager, but don't block them completely.
577 if (var_in_flow_delay
> 0) {
578 token_count
= mail_flow_count();
579 if (token_count
< var_proc_limit
) {
580 if (feed
!= 0 && last_scan_idx
== QMGR_SCAN_IDX_INCOMING
)
582 else if (qmgr_scans
[QMGR_SCAN_IDX_INCOMING
]->handle
== 0)
583 mail_flow_put(var_proc_limit
- token_count
);
584 } else if (token_count
> var_proc_limit
) {
585 mail_flow_get(token_count
- var_proc_limit
);
591 /* pre_accept - see if tables have changed */
593 static void pre_accept(char *unused_name
, char **unused_argv
)
597 if ((table
= dict_changed_name()) != 0) {
598 msg_info("table %s has changed -- restarting", table
);
603 /* qmgr_pre_init - pre-jail initialization */
605 static void qmgr_pre_init(char *unused_name
, char **unused_argv
)
610 /* qmgr_post_init - post-jail initialization */
612 static void qmgr_post_init(char *name
, char **unused_argv
)
616 * Backwards compatibility.
618 if (strcmp(var_procname
, "nqmgr") == 0) {
619 msg_warn("please update the %s/%s file; the new queue manager",
620 var_config_dir
, MASTER_CONF_FILE
);
621 msg_warn("(old name: nqmgr) has become the standard queue manager (new name: qmgr)");
622 msg_warn("support for the name old name (nqmgr) will be removed from Postfix");
628 if (var_qmgr_rcpt_limit
< var_qmgr_active_limit
) {
629 msg_warn("%s is smaller than %s - adjusting %s",
630 VAR_QMGR_RCPT_LIMIT
, VAR_QMGR_ACT_LIMIT
, VAR_QMGR_RCPT_LIMIT
);
631 var_qmgr_rcpt_limit
= var_qmgr_active_limit
;
633 if (var_dsn_queue_time
> var_max_queue_time
) {
634 msg_warn("%s is larger than %s - adjusting %s",
635 VAR_DSN_QUEUE_TIME
, VAR_MAX_QUEUE_TIME
, VAR_DSN_QUEUE_TIME
);
636 var_dsn_queue_time
= var_max_queue_time
;
640 * This routine runs after the skeleton code has entered the chroot jail.
641 * Prevent automatic process suicide after a limited number of client
642 * requests or after a limited amount of idle time. Move any left-over
643 * entries from the active queue to the incoming queue, and give them a
644 * time stamp into the future, in order to allow ongoing deliveries to
645 * finish first. Start scanning the incoming and deferred queues.
646 * Left-over active queue entries are moved to the incoming queue because
647 * the incoming queue has priority; moving left-overs to the deferred
648 * queue could cause anomalous delays when "postfix reload/start" are
653 qmgr_move(MAIL_QUEUE_ACTIVE
, MAIL_QUEUE_INCOMING
, event_time());
654 qmgr_scans
[QMGR_SCAN_IDX_INCOMING
] = qmgr_scan_create(MAIL_QUEUE_INCOMING
);
655 qmgr_scans
[QMGR_SCAN_IDX_DEFERRED
] = qmgr_scan_create(MAIL_QUEUE_DEFERRED
);
656 qmgr_scan_request(qmgr_scans
[QMGR_SCAN_IDX_INCOMING
], QMGR_SCAN_START
);
657 qmgr_deferred_run_event(0, (char *) 0);
660 MAIL_VERSION_STAMP_DECLARE
;
662 /* main - the main program */
664 int main(int argc
, char **argv
)
666 static const CONFIG_STR_TABLE str_table
[] = {
667 VAR_DEFER_XPORTS
, DEF_DEFER_XPORTS
, &var_defer_xports
, 0, 0,
668 VAR_CONC_POS_FDBACK
, DEF_CONC_POS_FDBACK
, &var_conc_pos_feedback
, 1, 0,
669 VAR_CONC_NEG_FDBACK
, DEF_CONC_NEG_FDBACK
, &var_conc_neg_feedback
, 1, 0,
672 static const CONFIG_TIME_TABLE time_table
[] = {
673 VAR_QUEUE_RUN_DELAY
, DEF_QUEUE_RUN_DELAY
, &var_queue_run_delay
, 1, 0,
674 VAR_MIN_BACKOFF_TIME
, DEF_MIN_BACKOFF_TIME
, &var_min_backoff_time
, 1, 0,
675 VAR_MAX_BACKOFF_TIME
, DEF_MAX_BACKOFF_TIME
, &var_max_backoff_time
, 1, 0,
676 VAR_MAX_QUEUE_TIME
, DEF_MAX_QUEUE_TIME
, &var_max_queue_time
, 0, 8640000,
677 VAR_DSN_QUEUE_TIME
, DEF_DSN_QUEUE_TIME
, &var_dsn_queue_time
, 0, 8640000,
678 VAR_XPORT_RETRY_TIME
, DEF_XPORT_RETRY_TIME
, &var_transport_retry_time
, 1, 0,
679 VAR_QMGR_CLOG_WARN_TIME
, DEF_QMGR_CLOG_WARN_TIME
, &var_qmgr_clog_warn_time
, 0, 0,
680 VAR_XPORT_REFILL_DELAY
, DEF_XPORT_REFILL_DELAY
, &var_xport_refill_delay
, 1, 0,
681 VAR_DEST_RATE_DELAY
, DEF_DEST_RATE_DELAY
, &var_dest_rate_delay
, 0, 0,
684 static const CONFIG_INT_TABLE int_table
[] = {
685 VAR_QMGR_ACT_LIMIT
, DEF_QMGR_ACT_LIMIT
, &var_qmgr_active_limit
, 1, 0,
686 VAR_QMGR_RCPT_LIMIT
, DEF_QMGR_RCPT_LIMIT
, &var_qmgr_rcpt_limit
, 1, 0,
687 VAR_QMGR_MSG_RCPT_LIMIT
, DEF_QMGR_MSG_RCPT_LIMIT
, &var_qmgr_msg_rcpt_limit
, 1, 0,
688 VAR_XPORT_RCPT_LIMIT
, DEF_XPORT_RCPT_LIMIT
, &var_xport_rcpt_limit
, 0, 0,
689 VAR_STACK_RCPT_LIMIT
, DEF_STACK_RCPT_LIMIT
, &var_stack_rcpt_limit
, 0, 0,
690 VAR_XPORT_REFILL_LIMIT
, DEF_XPORT_REFILL_LIMIT
, &var_xport_refill_limit
, 1, 0,
691 VAR_DELIVERY_SLOT_COST
, DEF_DELIVERY_SLOT_COST
, &var_delivery_slot_cost
, 0, 0,
692 VAR_DELIVERY_SLOT_LOAN
, DEF_DELIVERY_SLOT_LOAN
, &var_delivery_slot_loan
, 0, 0,
693 VAR_DELIVERY_SLOT_DISCOUNT
, DEF_DELIVERY_SLOT_DISCOUNT
, &var_delivery_slot_discount
, 0, 100,
694 VAR_MIN_DELIVERY_SLOTS
, DEF_MIN_DELIVERY_SLOTS
, &var_min_delivery_slots
, 0, 0,
695 VAR_INIT_DEST_CON
, DEF_INIT_DEST_CON
, &var_init_dest_concurrency
, 1, 0,
696 VAR_DEST_CON_LIMIT
, DEF_DEST_CON_LIMIT
, &var_dest_con_limit
, 0, 0,
697 VAR_DEST_RCPT_LIMIT
, DEF_DEST_RCPT_LIMIT
, &var_dest_rcpt_limit
, 0, 0,
698 VAR_LOCAL_RCPT_LIMIT
, DEF_LOCAL_RCPT_LIMIT
, &var_local_rcpt_lim
, 0, 0,
699 VAR_LOCAL_CON_LIMIT
, DEF_LOCAL_CON_LIMIT
, &var_local_con_lim
, 0, 0,
700 VAR_PROC_LIMIT
, DEF_PROC_LIMIT
, &var_proc_limit
, 1, 0,
701 VAR_CONC_COHORT_LIM
, DEF_CONC_COHORT_LIM
, &var_conc_cohort_limit
, 0, 0,
704 static const CONFIG_BOOL_TABLE bool_table
[] = {
705 VAR_VERP_BOUNCE_OFF
, DEF_VERP_BOUNCE_OFF
, &var_verp_bounce_off
,
706 VAR_CONC_FDBACK_DEBUG
, DEF_CONC_FDBACK_DEBUG
, &var_conc_feedback_debug
,
711 * Fingerprint executables and core dumps.
713 MAIL_VERSION_STAMP_ALLOCATE
;
716 * Use the trigger service skeleton, because no-one else should be
717 * monitoring our service port while this process runs, and because we do
718 * not talk back to the client.
720 trigger_server_main(argc
, argv
, qmgr_trigger_event
,
721 MAIL_SERVER_INT_TABLE
, int_table
,
722 MAIL_SERVER_STR_TABLE
, str_table
,
723 MAIL_SERVER_BOOL_TABLE
, bool_table
,
724 MAIL_SERVER_TIME_TABLE
, time_table
,
725 MAIL_SERVER_PRE_INIT
, qmgr_pre_init
,
726 MAIL_SERVER_POST_INIT
, qmgr_post_init
,
727 MAIL_SERVER_LOOP
, qmgr_loop
,
728 MAIL_SERVER_PRE_ACCEPT
, pre_accept
,
729 MAIL_SERVER_SOLITARY
,