From 3b9aae9ea8eb5b7f4969226be310a9ea4313c315 Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Tue, 8 Nov 2005 00:00:00 -0500 Subject: [PATCH] postfix-2.3-20051108 --- postfix/HISTORY | 17 +- postfix/README_FILES/ADDRESS_REWRITING_README | 8 +- postfix/html/ADDRESS_REWRITING_README.html | 8 +- postfix/html/cleanup.8.html | 31 ++-- postfix/html/discard.8.html | 25 ++- postfix/html/error.8.html | 27 ++- postfix/html/lmtp.8.html | 29 ++-- postfix/html/local.8.html | 43 +++-- postfix/html/oqmgr.8.html | 21 ++- postfix/html/pipe.8.html | 27 ++- postfix/html/postconf.5.html | 18 +- postfix/html/qmgr.8.html | 21 ++- postfix/html/smtp.8.html | 41 +++-- postfix/html/virtual.8.html | 35 ++-- postfix/man/man5/postconf.5 | 16 +- postfix/man/man8/cleanup.8 | 6 +- postfix/man/man8/discard.8 | 6 +- postfix/man/man8/error.8 | 6 +- postfix/man/man8/lmtp.8 | 6 +- postfix/man/man8/local.8 | 6 +- postfix/man/man8/oqmgr.8 | 6 +- postfix/man/man8/pipe.8 | 6 +- postfix/man/man8/qmgr.8 | 6 +- postfix/man/man8/smtp.8 | 6 +- postfix/man/man8/virtual.8 | 6 +- postfix/mantools/postlink | 2 +- postfix/pflogsumm-conn-delays-dsn-patch | 14 ++ postfix/pflogsumm-dsn-patch | 23 --- postfix/proto/ADDRESS_REWRITING_README.html | 8 +- postfix/proto/postconf.proto | 16 +- postfix/src/cleanup/cleanup.c | 6 +- postfix/src/cleanup/cleanup_message.c | 8 +- postfix/src/discard/discard.c | 6 +- postfix/src/error/error.c | 6 +- postfix/src/global/Makefile.in | 1 + postfix/src/global/log_adhoc.c | 23 +-- postfix/src/global/mail_params.c | 6 +- postfix/src/global/mail_params.h | 12 +- postfix/src/global/mail_queue.c | 37 ++--- postfix/src/global/mail_queue.h | 7 +- postfix/src/global/mail_stream.c | 9 +- postfix/src/global/mail_stream.h | 6 + postfix/src/global/mail_version.h | 2 +- postfix/src/lmtp/lmtp.c | 6 +- postfix/src/local/local.c | 6 +- postfix/src/oqmgr/qmgr.c | 6 +- postfix/src/pipe/pipe.c | 6 +- postfix/src/qmgr/qmgr.c | 6 +- postfix/src/smtp/smtp.c | 6 +- postfix/src/util/Makefile.in | 26 ++- postfix/src/util/format_tv.c | 156 ++++++++++++++++++ postfix/src/util/format_tv.h | 35 ++++ postfix/src/util/format_tv.in | 68 ++++++++ postfix/src/util/format_tv.ref | 120 ++++++++++++++ postfix/src/util/vstream.c | 14 +- postfix/src/util/vstream.h | 6 +- postfix/src/virtual/virtual.c | 6 +- 57 files changed, 747 insertions(+), 339 deletions(-) create mode 100644 postfix/pflogsumm-conn-delays-dsn-patch delete mode 100644 postfix/pflogsumm-dsn-patch create mode 100644 postfix/src/util/format_tv.c create mode 100644 postfix/src/util/format_tv.h create mode 100644 postfix/src/util/format_tv.in create mode 100644 postfix/src/util/format_tv.ref diff --git a/postfix/HISTORY b/postfix/HISTORY index 923d9d9c7..571aa23c5 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -11301,6 +11301,7 @@ Apologies for any names omitted. microseconds, or 0.01 second) that controls the detail in the new "delays=a/b/c/d" logging. Specify a power of 10 in the range from 1 to 100000. File: global/log_adhoc.c. + Parameter renamed 20051108. 20051105 @@ -11314,7 +11315,7 @@ Apologies for any names omitted. smtpd/smtpd.c, qmqpd/qmqpd.c, *qmgr/qmgr_message.c, *qmgr/qmgr_active.c, local/forward.c. -20061106 +20051106 The SMTP client logs the remote server port in the form of relay=hostname[hostaddr]:port to the local maillog file. @@ -11327,6 +11328,20 @@ Apologies for any names omitted. with a few simple macros, to make future changes in time representation less painful. +20051108 + + Cleanup: eliminated floating point operations from the + ad-hoc delay logging code. Files: util/format_tv.[hc], + global/log_adhoc.c. + + The delay logging resolution is now controlled with the + delay_logging_resolution_limit parameter, which specifies + the maximal number of digits after the decimal point. + + Bugfix: under unlikely conditions two messages could get + the same message ID. Found by Victor. Files: global/mail_stream.c, + global/mail_queue.c. + Open problems: "postsuper -r" no longer resets the message arrival time, diff --git a/postfix/README_FILES/ADDRESS_REWRITING_README b/postfix/README_FILES/ADDRESS_REWRITING_README index f433ec3a5..20bf368d8 100644 --- a/postfix/README_FILES/ADDRESS_REWRITING_README +++ b/postfix/README_FILES/ADDRESS_REWRITING_README @@ -367,7 +367,7 @@ Example: /etc/postfix/master.cf: :10026 inet n - n - - smtpd - -o receive_override_options=no_address_mapping + -o receive_override_options=no_address_mappings Note: do not specify whitespace around the "=" here. @@ -440,7 +440,7 @@ Example: /etc/postfix/master.cf: :10026 inet n - n - - smtpd - -o receive_override_options=no_address_mapping + -o receive_override_options=nso_address_mapping Note: do not specify whitespace around the "=" here. @@ -476,7 +476,7 @@ Example: /etc/postfix/master.cf: :10026 inet n - n - - smtpd - -o receive_override_options=no_address_mapping + -o receive_override_options=no_address_mappings Note: do not specify whitespace around the "=" here. @@ -525,7 +525,7 @@ Example: /etc/postfix/master.cf: :10026 inet n - n - - smtpd - -o receive_override_options=no_address_mapping + -o receive_override_options=no_address_mappings Note: do not specify whitespace around the "=" here. diff --git a/postfix/html/ADDRESS_REWRITING_README.html b/postfix/html/ADDRESS_REWRITING_README.html index 226d937be..f2dd917eb 100644 --- a/postfix/html/ADDRESS_REWRITING_README.html +++ b/postfix/html/ADDRESS_REWRITING_README.html @@ -603,7 +603,7 @@ in the master.cf file. This feature is available in Postfix version
 /etc/postfix/master.cf:
     :10026      inet  n       -       n       -       -       smtpd
-        -o receive_override_options=no_address_mapping
+        -o receive_override_options=no_address_mappings
 
@@ -702,7 +702,7 @@ Postfix version 2.1 and later.

 /etc/postfix/master.cf:
     :10026      inet  n       -       n       -       -       smtpd
-        -o receive_override_options=no_address_mapping
+        -o receive_override_options=nso_address_mapping
 
@@ -752,7 +752,7 @@ is available in Postfix version 2.1 and later.

 /etc/postfix/master.cf:
     :10026      inet  n       -       n       -       -       smtpd
-        -o receive_override_options=no_address_mapping
+        -o receive_override_options=no_address_mappings
 
@@ -816,7 +816,7 @@ in the master.cf file. This feature is available in Postfix version
 /etc/postfix/master.cf:
     :10026      inet  n       -       n       -       -       smtpd
-        -o receive_override_options=no_address_mapping
+        -o receive_override_options=no_address_mappings
 
diff --git a/postfix/html/cleanup.8.html b/postfix/html/cleanup.8.html index 11c472408..a5f60db28 100644 --- a/postfix/html/cleanup.8.html +++ b/postfix/html/cleanup.8.html @@ -322,13 +322,12 @@ CLEANUP(8) CLEANUP(8) handle a request before it is terminated by a built-in watchdog timer. - delay_logging_time_resolution (10000) - The time resolution (microseconds) of the sub-sec- - ond delay values that are logged for subsequent - message delivery stages. + delay_logging_resolution_limit (2) + The maximal number of digits after the decimal + point when logging sub-second delay values. delay_warning_time (0h) - The time after which the sender receives the mes- + The time after which the sender receives the mes- sage headers of mail that is still queued. ipc_timeout (3600s) @@ -336,12 +335,12 @@ CLEANUP(8) CLEANUP(8) over an internal communication channel. max_idle (100s) - The maximum amount of time that an idle Postfix - daemon process waits for the next service request + The maximum amount of time that an idle Postfix + daemon process waits for the next service request before exiting. max_use (100) - The maximal number of connection requests before a + The maximal number of connection requests before a Postfix daemon process terminates. myhostname (see 'postconf -d' output) @@ -349,19 +348,19 @@ CLEANUP(8) CLEANUP(8) myorigin ($myhostname) The domain name that locally-posted mail appears to - come from, and that locally posted mail is deliv- + come from, and that locally posted mail is deliv- ered to. process_id (read-only) - The process ID of a Postfix command or daemon + The process ID of a Postfix command or daemon process. process_name (read-only) - The process name of a Postfix command or daemon + The process name of a Postfix command or daemon process. queue_directory (see 'postconf -d' output) - The location of the Postfix top-level queue direc- + The location of the Postfix top-level queue direc- tory. soft_bounce (no) @@ -372,14 +371,14 @@ CLEANUP(8) CLEANUP(8) The syslog facility of Postfix logging. syslog_name (postfix) - The mail system name that is prepended to the - process name in syslog records, so that "smtpd" + The mail system name that is prepended to the + process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". Available in Postfix version 2.1 and later: enable_original_recipient (yes) - Enable support for the X-Original-To message + Enable support for the X-Original-To message header. FILES @@ -402,7 +401,7 @@ CLEANUP(8) CLEANUP(8) ADDRESS_REWRITING_README Postfix address manipulation LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) diff --git a/postfix/html/discard.8.html b/postfix/html/discard.8.html index 87a1d1f8b..01fd6d459 100644 --- a/postfix/html/discard.8.html +++ b/postfix/html/discard.8.html @@ -63,10 +63,9 @@ DISCARD(8) DISCARD(8) handle a request before it is terminated by a built-in watchdog timer. - delay_logging_time_resolution (10000) - The time resolution (microseconds) of the sub-sec- - ond delay values that are logged for subsequent - message delivery stages. + delay_logging_resolution_limit (2) + The maximal number of digits after the decimal + point when logging sub-second delay values. double_bounce_sender (double-bounce) The sender address of postmaster notifications that @@ -77,32 +76,32 @@ DISCARD(8) DISCARD(8) over an internal communication channel. max_idle (100s) - The maximum amount of time that an idle Postfix - daemon process waits for the next service request + The maximum amount of time that an idle Postfix + daemon process waits for the next service request before exiting. max_use (100) - The maximal number of connection requests before a + The maximal number of connection requests before a Postfix daemon process terminates. process_id (read-only) - The process ID of a Postfix command or daemon + The process ID of a Postfix command or daemon process. process_name (read-only) - The process name of a Postfix command or daemon + The process name of a Postfix command or daemon process. queue_directory (see 'postconf -d' output) - The location of the Postfix top-level queue direc- + The location of the Postfix top-level queue direc- tory. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (postfix) - The mail system name that is prepended to the - process name in syslog records, so that "smtpd" + The mail system name that is prepended to the + process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". SEE ALSO @@ -115,7 +114,7 @@ DISCARD(8) DISCARD(8) syslogd(8), system logging LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. HISTORY diff --git a/postfix/html/error.8.html b/postfix/html/error.8.html index 0e085182e..338b6c9fd 100644 --- a/postfix/html/error.8.html +++ b/postfix/html/error.8.html @@ -73,10 +73,9 @@ ERROR(8) ERROR(8) handle a request before it is terminated by a built-in watchdog timer. - delay_logging_time_resolution (10000) - The time resolution (microseconds) of the sub-sec- - ond delay values that are logged for subsequent - message delivery stages. + delay_logging_resolution_limit (2) + The maximal number of digits after the decimal + point when logging sub-second delay values. double_bounce_sender (double-bounce) The sender address of postmaster notifications that @@ -87,36 +86,36 @@ ERROR(8) ERROR(8) over an internal communication channel. max_idle (100s) - The maximum amount of time that an idle Postfix - daemon process waits for the next service request + The maximum amount of time that an idle Postfix + daemon process waits for the next service request before exiting. max_use (100) - The maximal number of connection requests before a + The maximal number of connection requests before a Postfix daemon process terminates. notify_classes (resource, software) - The list of error classes that are reported to the + The list of error classes that are reported to the postmaster. process_id (read-only) - The process ID of a Postfix command or daemon + The process ID of a Postfix command or daemon process. process_name (read-only) - The process name of a Postfix command or daemon + The process name of a Postfix command or daemon process. queue_directory (see 'postconf -d' output) - The location of the Postfix top-level queue direc- + The location of the Postfix top-level queue direc- tory. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (postfix) - The mail system name that is prepended to the - process name in syslog records, so that "smtpd" + The mail system name that is prepended to the + process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". SEE ALSO @@ -129,7 +128,7 @@ ERROR(8) ERROR(8) syslogd(8), system logging LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) diff --git a/postfix/html/lmtp.8.html b/postfix/html/lmtp.8.html index 107312ea3..a8b4ab2cd 100644 --- a/postfix/html/lmtp.8.html +++ b/postfix/html/lmtp.8.html @@ -217,13 +217,12 @@ LMTP(8) LMTP(8) handle a request before it is terminated by a built-in watchdog timer. - delay_logging_time_resolution (10000) - The time resolution (microseconds) of the sub-sec- - ond delay values that are logged for subsequent - message delivery stages. + delay_logging_resolution_limit (2) + The maximal number of digits after the decimal + point when logging sub-second delay values. disable_dns_lookups (no) - Disable DNS lookups in the Postfix SMTP and LMTP + Disable DNS lookups in the Postfix SMTP and LMTP clients. ipc_timeout (3600s) @@ -231,36 +230,36 @@ LMTP(8) LMTP(8) over an internal communication channel. lmtp_tcp_port (24) - The default TCP port that the Postfix LMTP client + The default TCP port that the Postfix LMTP client connects to. max_idle (100s) - The maximum amount of time that an idle Postfix - daemon process waits for the next service request + The maximum amount of time that an idle Postfix + daemon process waits for the next service request before exiting. max_use (100) - The maximal number of connection requests before a + The maximal number of connection requests before a Postfix daemon process terminates. process_id (read-only) - The process ID of a Postfix command or daemon + The process ID of a Postfix command or daemon process. process_name (read-only) - The process name of a Postfix command or daemon + The process name of a Postfix command or daemon process. queue_directory (see 'postconf -d' output) - The location of the Postfix top-level queue direc- + The location of the Postfix top-level queue direc- tory. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (postfix) - The mail system name that is prepended to the - process name in syslog records, so that "smtpd" + The mail system name that is prepended to the + process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". SEE ALSO @@ -277,7 +276,7 @@ LMTP(8) LMTP(8) VIRTUAL_README, virtual delivery agent howto LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) diff --git a/postfix/html/local.8.html b/postfix/html/local.8.html index 42cb05ce9..35a836dbe 100644 --- a/postfix/html/local.8.html +++ b/postfix/html/local.8.html @@ -521,13 +521,12 @@ LOCAL(8) LOCAL(8) handle a request before it is terminated by a built-in watchdog timer. - delay_logging_time_resolution (10000) - The time resolution (microseconds) of the sub-sec- - ond delay values that are logged for subsequent - message delivery stages. + delay_logging_resolution_limit (2) + The maximal number of digits after the decimal + point when logging sub-second delay values. export_environment (see 'postconf -d' output) - The list of environment variables that a Postfix + The list of environment variables that a Postfix process will export to non-Postfix processes. ipc_timeout (3600s) @@ -535,38 +534,38 @@ LOCAL(8) LOCAL(8) over an internal communication channel. local_command_shell (empty) - Optional shell program for local(8) delivery to + Optional shell program for local(8) delivery to non-Postfix command. max_idle (100s) - The maximum amount of time that an idle Postfix - daemon process waits for the next service request + The maximum amount of time that an idle Postfix + daemon process waits for the next service request before exiting. max_use (100) - The maximal number of connection requests before a + The maximal number of connection requests before a Postfix daemon process terminates. prepend_delivered_header (command, file, forward) - The message delivery contexts where the Postfix - local(8) delivery agent prepends a Delivered-To: - message header with the address that the mail was + The message delivery contexts where the Postfix + local(8) delivery agent prepends a Delivered-To: + message header with the address that the mail was delivered to. process_id (read-only) - The process ID of a Postfix command or daemon + The process ID of a Postfix command or daemon process. process_name (read-only) - The process name of a Postfix command or daemon + The process name of a Postfix command or daemon process. propagate_unmatched_extensions (canonical, virtual) - What address lookup tables copy an address exten- + What address lookup tables copy an address exten- sion from the lookup key to the lookup result. queue_directory (see 'postconf -d' output) - The location of the Postfix top-level queue direc- + The location of the Postfix top-level queue direc- tory. recipient_delimiter (empty) @@ -574,15 +573,15 @@ LOCAL(8) LOCAL(8) sions (user+foo). require_home_directory (no) - Whether or not a local(8) recipient's home direc- - tory must exist before mail delivery is attempted. + Whether or not a local(8) recipient's home direc- + tory must exist before mail delivery is attempted. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (postfix) - The mail system name that is prepended to the - process name in syslog records, so that "smtpd" + The mail system name that is prepended to the + process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". FILES @@ -602,14 +601,14 @@ LOCAL(8) LOCAL(8) syslogd(8), system logging LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. HISTORY The Delivered-To: message header appears in the qmail sys- tem by Daniel Bernstein. - The maildir structure appears in the qmail system by + The maildir structure appears in the qmail system by Daniel Bernstein. AUTHOR(S) diff --git a/postfix/html/oqmgr.8.html b/postfix/html/oqmgr.8.html index 2c8de10eb..6e25a01e7 100644 --- a/postfix/html/oqmgr.8.html +++ b/postfix/html/oqmgr.8.html @@ -274,13 +274,12 @@ OQMGR(8) OQMGR(8) should not deliver mail unless someone issues "sendmail -q" or equivalent. - delay_logging_time_resolution (10000) - The time resolution (microseconds) of the sub-sec- - ond delay values that are logged for subsequent - message delivery stages. + delay_logging_resolution_limit (2) + The maximal number of digits after the decimal + point when logging sub-second delay values. helpful_warnings (yes) - Log warnings about problematic configuration set- + Log warnings about problematic configuration set- tings, and provide helpful suggestions. ipc_timeout (3600s) @@ -288,23 +287,23 @@ OQMGR(8) OQMGR(8) over an internal communication channel. process_id (read-only) - The process ID of a Postfix command or daemon + The process ID of a Postfix command or daemon process. process_name (read-only) - The process name of a Postfix command or daemon + The process name of a Postfix command or daemon process. queue_directory (see 'postconf -d' output) - The location of the Postfix top-level queue direc- + The location of the Postfix top-level queue direc- tory. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (postfix) - The mail system name that is prepended to the - process name in syslog records, so that "smtpd" + The mail system name that is prepended to the + process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". FILES @@ -327,7 +326,7 @@ OQMGR(8) OQMGR(8) QSHAPE_README, Postfix queue analysis LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) diff --git a/postfix/html/pipe.8.html b/postfix/html/pipe.8.html index bcb094041..faa3c00f4 100644 --- a/postfix/html/pipe.8.html +++ b/postfix/html/pipe.8.html @@ -368,13 +368,12 @@ PIPE(8) PIPE(8) handle a request before it is terminated by a built-in watchdog timer. - delay_logging_time_resolution (10000) - The time resolution (microseconds) of the sub-sec- - ond delay values that are logged for subsequent - message delivery stages. + delay_logging_resolution_limit (2) + The maximal number of digits after the decimal + point when logging sub-second delay values. export_environment (see 'postconf -d' output) - The list of environment variables that a Postfix + The list of environment variables that a Postfix process will export to non-Postfix processes. ipc_timeout (3600s) @@ -386,24 +385,24 @@ PIPE(8) PIPE(8) and most Postfix daemon processes. max_idle (100s) - The maximum amount of time that an idle Postfix - daemon process waits for the next service request + The maximum amount of time that an idle Postfix + daemon process waits for the next service request before exiting. max_use (100) - The maximal number of connection requests before a + The maximal number of connection requests before a Postfix daemon process terminates. process_id (read-only) - The process ID of a Postfix command or daemon + The process ID of a Postfix command or daemon process. process_name (read-only) - The process name of a Postfix command or daemon + The process name of a Postfix command or daemon process. queue_directory (see 'postconf -d' output) - The location of the Postfix top-level queue direc- + The location of the Postfix top-level queue direc- tory. recipient_delimiter (empty) @@ -414,8 +413,8 @@ PIPE(8) PIPE(8) The syslog facility of Postfix logging. syslog_name (postfix) - The mail system name that is prepended to the - process name in syslog records, so that "smtpd" + The mail system name that is prepended to the + process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". SEE ALSO @@ -427,7 +426,7 @@ PIPE(8) PIPE(8) syslogd(8), system logging LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) diff --git a/postfix/html/postconf.5.html b/postfix/html/postconf.5.html index 4a0b822f4..7bea38b3a 100644 --- a/postfix/html/postconf.5.html +++ b/postfix/html/postconf.5.html @@ -1902,12 +1902,16 @@ Example: -
delay_logging_time_resolution -(default: 10000)
+
delay_logging_resolution_limit +(default: 2)
-

The time resolution (microseconds) of the sub-second delay -values that are logged for subsequent message delivery stages. -Specify a power of 10 in the range from 1 to 100000.

+

The maximal number of digits after the decimal point when logging +sub-second delay values. Specify a number in the range 0..6.

+ +

Large delay values are rounded off to an integral number seconds; +delay values below the delay_logging_resolution_limit are logged +as "0", and small delay values are logged with at most two-digit +precision.

The format of the "delays=a/b/c/d" logging is as follows:

@@ -1923,9 +1927,7 @@ Specify a power of 10 in the range from 1 to 100000.

-

Delay values less than delay_logging_time_resolution are logged -as "0", while delay values less than 10s are logged with at most -two-digit precision.

+

This feature is available in Postfix 2.3 and later.

diff --git a/postfix/html/qmgr.8.html b/postfix/html/qmgr.8.html index 70a51b8d8..e74a5817a 100644 --- a/postfix/html/qmgr.8.html +++ b/postfix/html/qmgr.8.html @@ -329,13 +329,12 @@ QMGR(8) QMGR(8) should not deliver mail unless someone issues "sendmail -q" or equivalent. - delay_logging_time_resolution (10000) - The time resolution (microseconds) of the sub-sec- - ond delay values that are logged for subsequent - message delivery stages. + delay_logging_resolution_limit (2) + The maximal number of digits after the decimal + point when logging sub-second delay values. helpful_warnings (yes) - Log warnings about problematic configuration set- + Log warnings about problematic configuration set- tings, and provide helpful suggestions. ipc_timeout (3600s) @@ -343,23 +342,23 @@ QMGR(8) QMGR(8) over an internal communication channel. process_id (read-only) - The process ID of a Postfix command or daemon + The process ID of a Postfix command or daemon process. process_name (read-only) - The process name of a Postfix command or daemon + The process name of a Postfix command or daemon process. queue_directory (see 'postconf -d' output) - The location of the Postfix top-level queue direc- + The location of the Postfix top-level queue direc- tory. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (postfix) - The mail system name that is prepended to the - process name in syslog records, so that "smtpd" + The mail system name that is prepended to the + process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". FILES @@ -383,7 +382,7 @@ QMGR(8) QMGR(8) QSHAPE_README, Postfix queue analysis LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) diff --git a/postfix/html/smtp.8.html b/postfix/html/smtp.8.html index 76f5c6541..e01c21b07 100644 --- a/postfix/html/smtp.8.html +++ b/postfix/html/smtp.8.html @@ -418,17 +418,16 @@ SMTP(8) SMTP(8) handle a request before it is terminated by a built-in watchdog timer. - delay_logging_time_resolution (10000) - The time resolution (microseconds) of the sub-sec- - ond delay values that are logged for subsequent - message delivery stages. + delay_logging_resolution_limit (2) + The maximal number of digits after the decimal + point when logging sub-second delay values. disable_dns_lookups (no) - Disable DNS lookups in the Postfix SMTP and LMTP + Disable DNS lookups in the Postfix SMTP and LMTP clients. fallback_relay (empty) - Optional list of relay hosts for SMTP destinations + Optional list of relay hosts for SMTP destinations that can't be found or that are unreachable. inet_interfaces (all) @@ -436,7 +435,7 @@ SMTP(8) SMTP(8) tem receives mail on. inet_protocols (ipv4) - The Internet protocols Postfix will attempt to use + The Internet protocols Postfix will attempt to use when making or accepting connections. ipc_timeout (3600s) @@ -444,55 +443,55 @@ SMTP(8) SMTP(8) over an internal communication channel. max_idle (100s) - The maximum amount of time that an idle Postfix - daemon process waits for the next service request + The maximum amount of time that an idle Postfix + daemon process waits for the next service request before exiting. max_use (100) - The maximal number of connection requests before a + The maximal number of connection requests before a Postfix daemon process terminates. process_id (read-only) - The process ID of a Postfix command or daemon + The process ID of a Postfix command or daemon process. process_name (read-only) - The process name of a Postfix command or daemon + The process name of a Postfix command or daemon process. proxy_interfaces (empty) The network interface addresses that this mail sys- - tem receives mail on by way of a proxy or network + tem receives mail on by way of a proxy or network address translation unit. smtp_bind_address (empty) An optional numerical network address that the SMTP - client should bind to when making an IPv4 connec- + client should bind to when making an IPv4 connec- tion. smtp_bind_address6 (empty) An optional numerical network address that the SMTP - client should bind to when making an IPv6 connec- + client should bind to when making an IPv6 connec- tion. smtp_helo_name ($myhostname) - The hostname to send in the SMTP EHLO or HELO com- + The hostname to send in the SMTP EHLO or HELO com- mand. smtp_host_lookup (dns) - What mechanisms when the SMTP client uses to look + What mechanisms when the SMTP client uses to look up a host's IP address. smtp_randomize_addresses (yes) - Randomize the order of equal-preference MX host + Randomize the order of equal-preference MX host addresses. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (postfix) - The mail system name that is prepended to the - process name in syslog records, so that "smtpd" + The mail system name that is prepended to the + process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". SEE ALSO @@ -510,7 +509,7 @@ SMTP(8) SMTP(8) TLS_README, Postfix STARTTLS howto LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) diff --git a/postfix/html/virtual.8.html b/postfix/html/virtual.8.html index 535d63fc3..2af3c6a2d 100644 --- a/postfix/html/virtual.8.html +++ b/postfix/html/virtual.8.html @@ -238,42 +238,41 @@ VIRTUAL(8) VIRTUAL(8) handle a request before it is terminated by a built-in watchdog timer. - delay_logging_time_resolution (10000) - The time resolution (microseconds) of the sub-sec- - ond delay values that are logged for subsequent - message delivery stages. + delay_logging_resolution_limit (2) + The maximal number of digits after the decimal + point when logging sub-second delay values. ipc_timeout (3600s) The time limit for sending or receiving information over an internal communication channel. max_idle (100s) - The maximum amount of time that an idle Postfix - daemon process waits for the next service request + The maximum amount of time that an idle Postfix + daemon process waits for the next service request before exiting. max_use (100) - The maximal number of connection requests before a + The maximal number of connection requests before a Postfix daemon process terminates. process_id (read-only) - The process ID of a Postfix command or daemon + The process ID of a Postfix command or daemon process. process_name (read-only) - The process name of a Postfix command or daemon + The process name of a Postfix command or daemon process. queue_directory (see 'postconf -d' output) - The location of the Postfix top-level queue direc- + The location of the Postfix top-level queue direc- tory. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (postfix) - The mail system name that is prepended to the - process name in syslog records, so that "smtpd" + The mail system name that is prepended to the + process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". SEE ALSO @@ -286,20 +285,20 @@ VIRTUAL(8) VIRTUAL(8) VIRTUAL_README, domain hosting howto LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. HISTORY - This delivery agent was originally based on the Postfix - local delivery agent. Modifications mainly consisted of - removing code that either was not applicable or that was - not safe in this context: aliases, ~user/.forward files, + This delivery agent was originally based on the Postfix + local delivery agent. Modifications mainly consisted of + removing code that either was not applicable or that was + not safe in this context: aliases, ~user/.forward files, delivery to "|command" or to /file/name. The Delivered-To: message header appears in the qmail sys- tem by Daniel Bernstein. - The maildir structure appears in the qmail system by + The maildir structure appears in the qmail system by Daniel Bernstein. AUTHOR(S) diff --git a/postfix/man/man5/postconf.5 b/postfix/man/man5/postconf.5 index 2622fa1c0..b1b5b6768 100644 --- a/postfix/man/man5/postconf.5 +++ b/postfix/man/man5/postconf.5 @@ -1034,10 +1034,14 @@ defer_transports = smtp .fi .ad .ft R -.SH delay_logging_time_resolution (default: 10000) -The time resolution (microseconds) of the sub-second delay -values that are logged for subsequent message delivery stages. -Specify a power of 10 in the range from 1 to 100000. +.SH delay_logging_resolution_limit (default: 2) +The maximal number of digits after the decimal point when logging +sub-second delay values. Specify a number in the range 0..6. +.PP +Large delay values are rounded off to an integral number seconds; +delay values below the delay_logging_resolution_limit are logged +as "0", and small delay values are logged with at most two-digit +precision. .PP The format of the "delays=a/b/c/d" logging is as follows: .IP \(bu @@ -1049,9 +1053,7 @@ c = time in connection setup, including DNS, EHLO and TLS .IP \(bu d = time in message transmission .PP -Delay values less than delay_logging_time_resolution are logged -as "0", while delay values less than 10s are logged with at most -two-digit precision. +This feature is available in Postfix 2.3 and later. .SH delay_notice_recipient (default: postmaster) The recipient of postmaster notifications with the message headers of mail that cannot be delivered within $delay_warning_time time diff --git a/postfix/man/man8/cleanup.8 b/postfix/man/man8/cleanup.8 index 3ba92cf0f..8e2dad32a 100644 --- a/postfix/man/man8/cleanup.8 +++ b/postfix/man/man8/cleanup.8 @@ -270,9 +270,9 @@ configuration files. .IP "\fBdaemon_timeout (18000s)\fR" How much time a Postfix daemon process may take to handle a request before it is terminated by a built-in watchdog timer. -.IP "\fBdelay_logging_time_resolution (10000)\fR" -The time resolution (microseconds) of the sub-second delay -values that are logged for subsequent message delivery stages. +.IP "\fBdelay_logging_resolution_limit (2)\fR" +The maximal number of digits after the decimal point when logging +sub-second delay values. .IP "\fBdelay_warning_time (0h)\fR" The time after which the sender receives the message headers of mail that is still queued. diff --git a/postfix/man/man8/discard.8 b/postfix/man/man8/discard.8 index aa0cfca19..48256947b 100644 --- a/postfix/man/man8/discard.8 +++ b/postfix/man/man8/discard.8 @@ -64,9 +64,9 @@ configuration files. .IP "\fBdaemon_timeout (18000s)\fR" How much time a Postfix daemon process may take to handle a request before it is terminated by a built-in watchdog timer. -.IP "\fBdelay_logging_time_resolution (10000)\fR" -The time resolution (microseconds) of the sub-second delay -values that are logged for subsequent message delivery stages. +.IP "\fBdelay_logging_resolution_limit (2)\fR" +The maximal number of digits after the decimal point when logging +sub-second delay values. .IP "\fBdouble_bounce_sender (double-bounce)\fR" The sender address of postmaster notifications that are generated by the mail system. diff --git a/postfix/man/man8/error.8 b/postfix/man/man8/error.8 index a63044145..f5a19cf91 100644 --- a/postfix/man/man8/error.8 +++ b/postfix/man/man8/error.8 @@ -71,9 +71,9 @@ configuration files. .IP "\fBdaemon_timeout (18000s)\fR" How much time a Postfix daemon process may take to handle a request before it is terminated by a built-in watchdog timer. -.IP "\fBdelay_logging_time_resolution (10000)\fR" -The time resolution (microseconds) of the sub-second delay -values that are logged for subsequent message delivery stages. +.IP "\fBdelay_logging_resolution_limit (2)\fR" +The maximal number of digits after the decimal point when logging +sub-second delay values. .IP "\fBdouble_bounce_sender (double-bounce)\fR" The sender address of postmaster notifications that are generated by the mail system. diff --git a/postfix/man/man8/lmtp.8 b/postfix/man/man8/lmtp.8 index a967cd08f..09f8bde96 100644 --- a/postfix/man/man8/lmtp.8 +++ b/postfix/man/man8/lmtp.8 @@ -200,9 +200,9 @@ configuration files. .IP "\fBdaemon_timeout (18000s)\fR" How much time a Postfix daemon process may take to handle a request before it is terminated by a built-in watchdog timer. -.IP "\fBdelay_logging_time_resolution (10000)\fR" -The time resolution (microseconds) of the sub-second delay -values that are logged for subsequent message delivery stages. +.IP "\fBdelay_logging_resolution_limit (2)\fR" +The maximal number of digits after the decimal point when logging +sub-second delay values. .IP "\fBdisable_dns_lookups (no)\fR" Disable DNS lookups in the Postfix SMTP and LMTP clients. .IP "\fBipc_timeout (3600s)\fR" diff --git a/postfix/man/man8/local.8 b/postfix/man/man8/local.8 index 562098ffc..17ebdc14e 100644 --- a/postfix/man/man8/local.8 +++ b/postfix/man/man8/local.8 @@ -511,9 +511,9 @@ configuration files. .IP "\fBdaemon_timeout (18000s)\fR" How much time a Postfix daemon process may take to handle a request before it is terminated by a built-in watchdog timer. -.IP "\fBdelay_logging_time_resolution (10000)\fR" -The time resolution (microseconds) of the sub-second delay -values that are logged for subsequent message delivery stages. +.IP "\fBdelay_logging_resolution_limit (2)\fR" +The maximal number of digits after the decimal point when logging +sub-second delay values. .IP "\fBexport_environment (see 'postconf -d' output)\fR" The list of environment variables that a Postfix process will export to non-Postfix processes. diff --git a/postfix/man/man8/oqmgr.8 b/postfix/man/man8/oqmgr.8 index 62a715c3d..bd2ceafa9 100644 --- a/postfix/man/man8/oqmgr.8 +++ b/postfix/man/man8/oqmgr.8 @@ -255,9 +255,9 @@ request before it is terminated by a built-in watchdog timer. .IP "\fBdefer_transports (empty)\fR" The names of message delivery transports that should not deliver mail unless someone issues "\fBsendmail -q\fR" or equivalent. -.IP "\fBdelay_logging_time_resolution (10000)\fR" -The time resolution (microseconds) of the sub-second delay -values that are logged for subsequent message delivery stages. +.IP "\fBdelay_logging_resolution_limit (2)\fR" +The maximal number of digits after the decimal point when logging +sub-second delay values. .IP "\fBhelpful_warnings (yes)\fR" Log warnings about problematic configuration settings, and provide helpful suggestions. diff --git a/postfix/man/man8/pipe.8 b/postfix/man/man8/pipe.8 index 4661ff376..70da797c9 100644 --- a/postfix/man/man8/pipe.8 +++ b/postfix/man/man8/pipe.8 @@ -320,9 +320,9 @@ configuration files. .IP "\fBdaemon_timeout (18000s)\fR" How much time a Postfix daemon process may take to handle a request before it is terminated by a built-in watchdog timer. -.IP "\fBdelay_logging_time_resolution (10000)\fR" -The time resolution (microseconds) of the sub-second delay -values that are logged for subsequent message delivery stages. +.IP "\fBdelay_logging_resolution_limit (2)\fR" +The maximal number of digits after the decimal point when logging +sub-second delay values. .IP "\fBexport_environment (see 'postconf -d' output)\fR" The list of environment variables that a Postfix process will export to non-Postfix processes. diff --git a/postfix/man/man8/qmgr.8 b/postfix/man/man8/qmgr.8 index 150f03913..bca8945e3 100644 --- a/postfix/man/man8/qmgr.8 +++ b/postfix/man/man8/qmgr.8 @@ -294,9 +294,9 @@ request before it is terminated by a built-in watchdog timer. .IP "\fBdefer_transports (empty)\fR" The names of message delivery transports that should not deliver mail unless someone issues "\fBsendmail -q\fR" or equivalent. -.IP "\fBdelay_logging_time_resolution (10000)\fR" -The time resolution (microseconds) of the sub-second delay -values that are logged for subsequent message delivery stages. +.IP "\fBdelay_logging_resolution_limit (2)\fR" +The maximal number of digits after the decimal point when logging +sub-second delay values. .IP "\fBhelpful_warnings (yes)\fR" Log warnings about problematic configuration settings, and provide helpful suggestions. diff --git a/postfix/man/man8/smtp.8 b/postfix/man/man8/smtp.8 index d4691ded2..fe94efb71 100644 --- a/postfix/man/man8/smtp.8 +++ b/postfix/man/man8/smtp.8 @@ -340,9 +340,9 @@ configuration files. .IP "\fBdaemon_timeout (18000s)\fR" How much time a Postfix daemon process may take to handle a request before it is terminated by a built-in watchdog timer. -.IP "\fBdelay_logging_time_resolution (10000)\fR" -The time resolution (microseconds) of the sub-second delay -values that are logged for subsequent message delivery stages. +.IP "\fBdelay_logging_resolution_limit (2)\fR" +The maximal number of digits after the decimal point when logging +sub-second delay values. .IP "\fBdisable_dns_lookups (no)\fR" Disable DNS lookups in the Postfix SMTP and LMTP clients. .IP "\fBfallback_relay (empty)\fR" diff --git a/postfix/man/man8/virtual.8 b/postfix/man/man8/virtual.8 index 4bf9f9b8b..ca3b76163 100644 --- a/postfix/man/man8/virtual.8 +++ b/postfix/man/man8/virtual.8 @@ -245,9 +245,9 @@ configuration files. .IP "\fBdaemon_timeout (18000s)\fR" How much time a Postfix daemon process may take to handle a request before it is terminated by a built-in watchdog timer. -.IP "\fBdelay_logging_time_resolution (10000)\fR" -The time resolution (microseconds) of the sub-second delay -values that are logged for subsequent message delivery stages. +.IP "\fBdelay_logging_resolution_limit (2)\fR" +The maximal number of digits after the decimal point when logging +sub-second delay values. .IP "\fBipc_timeout (3600s)\fR" The time limit for sending or receiving information over an internal communication channel. diff --git a/postfix/mantools/postlink b/postfix/mantools/postlink index 11960f7a4..f2a655a71 100755 --- a/postfix/mantools/postlink +++ b/postfix/mantools/postlink @@ -139,7 +139,7 @@ while (<>) { s;\bdefer_code\b;$&;g; s;\bdefer_service_name\b;$&;g; s;\bdefer_transports\b;$&;g; - s;\bdelay_logging_time_resolution\b;$&;g; + s;\bdelay_logging_resolution_limit\b;$&;g; s;\bdelay_notice_recip[-]*\n* *[]*ient\b;$&;g; s;\bdelay_warning_time\b;$&;g; s;\bdeliver_lock_attempts\b;$&;g; diff --git a/postfix/pflogsumm-conn-delays-dsn-patch b/postfix/pflogsumm-conn-delays-dsn-patch new file mode 100644 index 000000000..be2698fd0 --- /dev/null +++ b/postfix/pflogsumm-conn-delays-dsn-patch @@ -0,0 +1,14 @@ +This patch adds support for logfiles with conn_use, delays, and dsn +attributes. + +--- pflogsumm.pl.orig 2005-04-09 12:54:44.000000000 +0200 ++++ pflogsumm.pl 2005-11-07 21:50:05.483199193 +0100 +@@ -696,7 +696,7 @@ + } + } + elsif((($addr, $relay, $delay, $status, $toRmdr) = $logRmdr =~ +- /to=<([^>]*)>, (?:orig_to=<[^>]*>, )?relay=([^,]+), delay=([^,]+), status=(\S+)(.*)$/o) >= 4) ++ /to=<([^>]*)>, (?:orig_to=<[^>]*>, )?relay=([^,]+), (?:conn_use=[^,]+, )?delay=([^,]+), (?:delays=[^,]+, )?(?:dsn=[^,]+, )?status=(\S+)(.*)$/o) >= 4) + { + + if($opts{'m'} && $addr =~ /^(.*!)*([^!]+)!([^!@]+)@([^\.]+)$/o) { diff --git a/postfix/pflogsumm-dsn-patch b/postfix/pflogsumm-dsn-patch deleted file mode 100644 index 6c312d616..000000000 --- a/postfix/pflogsumm-dsn-patch +++ /dev/null @@ -1,23 +0,0 @@ -Postfix 2.3 changes the logging format, introducing a field that -reports the delivery status code as "dsn=x.yy.zz", where yy and zz -can be up to three digits long. This breaks pflogsumm analysis. - -The patch below appeared in: - - Message-ID: <4257CF98.10309@michaweb.net> - Date: Sat, 09 Apr 2005 14:50:32 +0200 - From: John Fawcett - To: postfix-users@postfix.org - Subject: postfix 2.3 and pflogsumm - ---- pflogsumm.original 2005-04-09 12:54:44.140532258 +0200 -+++ pflogsumm 2005-04-09 12:55:33.246949650 +0200 -@@ -696,7 +696,7 @@ - } - } - elsif((($addr, $relay, $delay, $status, $toRmdr) = $logRmdr =~ -- /to=<([^>]*)>, (?:orig_to=<[^>]*>, )?relay=([^,]+), delay=([^,]+), status=(\S+)(.*)$/o) >= 4) -+ /to=<([^>]*)>, (?:orig_to=<[^>]*>, )?relay=([^,]+), delay=([^,]+), (?:dsn=\d+\.\d+\.\d+, )?status=(\S+)(.*)$/o) >= 4) - { - - if($opts{'m'} && $addr =~ /^(.*!)*([^!]+)!([^!@]+)@([^\.]+)$/o) { diff --git a/postfix/proto/ADDRESS_REWRITING_README.html b/postfix/proto/ADDRESS_REWRITING_README.html index 4955a6e8b..2f6130b61 100644 --- a/postfix/proto/ADDRESS_REWRITING_README.html +++ b/postfix/proto/ADDRESS_REWRITING_README.html @@ -603,7 +603,7 @@ in the master.cf file. This feature is available in Postfix version
 /etc/postfix/master.cf:
     :10026      inet  n       -       n       -       -       smtpd
-        -o receive_override_options=no_address_mapping
+        -o receive_override_options=no_address_mappings
 
@@ -702,7 +702,7 @@ Postfix version 2.1 and later.

 /etc/postfix/master.cf:
     :10026      inet  n       -       n       -       -       smtpd
-        -o receive_override_options=no_address_mapping
+        -o receive_override_options=nso_address_mapping
 
@@ -752,7 +752,7 @@ is available in Postfix version 2.1 and later.

 /etc/postfix/master.cf:
     :10026      inet  n       -       n       -       -       smtpd
-        -o receive_override_options=no_address_mapping
+        -o receive_override_options=no_address_mappings
 
@@ -816,7 +816,7 @@ in the master.cf file. This feature is available in Postfix version
 /etc/postfix/master.cf:
     :10026      inet  n       -       n       -       -       smtpd
-        -o receive_override_options=no_address_mapping
+        -o receive_override_options=no_address_mappings
 
diff --git a/postfix/proto/postconf.proto b/postfix/proto/postconf.proto index b26ae0ea6..802f413b1 100644 --- a/postfix/proto/postconf.proto +++ b/postfix/proto/postconf.proto @@ -8650,11 +8650,15 @@ the name matches the client IP address. A client name is set to lookup is disabled. Turning off name lookup reduces delays due to DNS lookup and increases the maximal inbound delivery rate.

-%PARAM delay_logging_time_resolution 10000 +%PARAM delay_logging_resolution_limit 2 -

The time resolution (microseconds) of the sub-second delay -values that are logged for subsequent message delivery stages. -Specify a power of 10 in the range from 1 to 100000.

+

The maximal number of digits after the decimal point when logging +sub-second delay values. Specify a number in the range 0..6.

+ +

Large delay values are rounded off to an integral number seconds; +delay values below the delay_logging_resolution_limit are logged +as "0", and small delay values are logged with at most two-digit +precision.

The format of the "delays=a/b/c/d" logging is as follows:

@@ -8670,6 +8674,4 @@ Specify a power of 10 in the range from 1 to 100000.

-

Delay values less than delay_logging_time_resolution are logged -as "0", while delay values less than 10s are logged with at most -two-digit precision.

+

This feature is available in Postfix 2.3 and later.

diff --git a/postfix/src/cleanup/cleanup.c b/postfix/src/cleanup/cleanup.c index 3c5a98bc3..5fbb28dbf 100644 --- a/postfix/src/cleanup/cleanup.c +++ b/postfix/src/cleanup/cleanup.c @@ -242,9 +242,9 @@ /* .IP "\fBdaemon_timeout (18000s)\fR" /* How much time a Postfix daemon process may take to handle a /* request before it is terminated by a built-in watchdog timer. -/* .IP "\fBdelay_logging_time_resolution (10000)\fR" -/* The time resolution (microseconds) of the sub-second delay -/* values that are logged for subsequent message delivery stages. +/* .IP "\fBdelay_logging_resolution_limit (2)\fR" +/* The maximal number of digits after the decimal point when logging +/* sub-second delay values. /* .IP "\fBdelay_warning_time (0h)\fR" /* The time after which the sender receives the message headers of /* mail that is still queued. diff --git a/postfix/src/cleanup/cleanup_message.c b/postfix/src/cleanup/cleanup_message.c index 644eb94bd..2d326bb1f 100644 --- a/postfix/src/cleanup/cleanup_message.c +++ b/postfix/src/cleanup/cleanup_message.c @@ -590,10 +590,16 @@ static void cleanup_header_done_callback(void *context) * * XXX It is the queue ID non-inode bits that prevent messages from getting * the same Message-Id within the same second. + * + * XXX An arbitrary amount of time may pass between the start of the mail + * transaction and the creation of a queue file. Since we guarantee queue + * ID uniqueness only within a second, we must ensure that the time in + * the message ID matches the queue ID creation time, if we use the queue + * ID in the message ID. */ if ((state->headers_seen & (1 << (state->resent[0] ? HDR_RESENT_MESSAGE_ID : HDR_MESSAGE_ID))) == 0) { - tv = state->arrival_time.tv_sec; + tv = state->handle->ctime.tv_sec; tp = gmtime(&tv); strftime(time_stamp, sizeof(time_stamp), "%Y%m%d%H%M%S", tp); cleanup_out_format(state, REC_TYPE_NORM, "%sMessage-Id: <%s.%s@%s>", diff --git a/postfix/src/discard/discard.c b/postfix/src/discard/discard.c index ecd01a253..5fb3e997e 100644 --- a/postfix/src/discard/discard.c +++ b/postfix/src/discard/discard.c @@ -50,9 +50,9 @@ /* .IP "\fBdaemon_timeout (18000s)\fR" /* How much time a Postfix daemon process may take to handle a /* request before it is terminated by a built-in watchdog timer. -/* .IP "\fBdelay_logging_time_resolution (10000)\fR" -/* The time resolution (microseconds) of the sub-second delay -/* values that are logged for subsequent message delivery stages. +/* .IP "\fBdelay_logging_resolution_limit (2)\fR" +/* The maximal number of digits after the decimal point when logging +/* sub-second delay values. /* .IP "\fBdouble_bounce_sender (double-bounce)\fR" /* The sender address of postmaster notifications that are generated /* by the mail system. diff --git a/postfix/src/error/error.c b/postfix/src/error/error.c index dbf7111e4..c7be3d6ec 100644 --- a/postfix/src/error/error.c +++ b/postfix/src/error/error.c @@ -57,9 +57,9 @@ /* .IP "\fBdaemon_timeout (18000s)\fR" /* How much time a Postfix daemon process may take to handle a /* request before it is terminated by a built-in watchdog timer. -/* .IP "\fBdelay_logging_time_resolution (10000)\fR" -/* The time resolution (microseconds) of the sub-second delay -/* values that are logged for subsequent message delivery stages. +/* .IP "\fBdelay_logging_resolution_limit (2)\fR" +/* The maximal number of digits after the decimal point when logging +/* sub-second delay values. /* .IP "\fBdouble_bounce_sender (double-bounce)\fR" /* The sender address of postmaster notifications that are generated /* by the mail system. diff --git a/postfix/src/global/Makefile.in b/postfix/src/global/Makefile.in index 5d9c5de30..a78a4716f 100644 --- a/postfix/src/global/Makefile.in +++ b/postfix/src/global/Makefile.in @@ -824,6 +824,7 @@ is_header.o: ../../include/sys_defs.h is_header.o: is_header.c is_header.o: is_header.h log_adhoc.o: ../../include/attr.h +log_adhoc.o: ../../include/format_tv.h log_adhoc.o: ../../include/msg.h log_adhoc.o: ../../include/sys_defs.h log_adhoc.o: ../../include/vbuf.h diff --git a/postfix/src/global/log_adhoc.c b/postfix/src/global/log_adhoc.c index a47bf08e2..4eee116ab 100644 --- a/postfix/src/global/log_adhoc.c +++ b/postfix/src/global/log_adhoc.c @@ -63,6 +63,7 @@ #include #include +#include /* Global library. */ @@ -179,26 +180,14 @@ void log_adhoc(const char *id, MSG_STATS *stats, RECIPIENT *recipient, } /* - * XXX Eliminate dependency on floating point. Wietse insists, however, - * that precision be limited to avoid logfile clutter. That is, numbers - * less than 100 must look as if they were formatted with %.2g, not as if - * they were formatted with %.2f, and numbers of 10 and up must have no - * sub-second detail at all. + * Round off large time values to an integral number of seconds, and + * display small numbers with only two digits as long as we stay above + * the time resolution. */ -#define MILLION 1000000 -#define DMILLION ((double) MILLION) - #define PRETTY_FORMAT(b, text, x) \ do { \ - if ((x).dt_sec > 9 \ - || ((x).dt_sec == 0 && (x).dt_usec < var_delay_resolution)) { \ - vstring_sprintf_append((b), text "%ld", \ - (long) (x).dt_sec + ((x).dt_usec > (MILLION / 2))); \ - } else { \ - vstring_sprintf_append((b), text "%.2g", (x).dt_sec \ - + ((x).dt_usec - (x).dt_usec % var_delay_resolution) \ - / DMILLION); \ - } \ + vstring_strcat((b), text); \ + format_tv((b), (x).dt_sec, (x).dt_usec, 2, var_delay_max_res); \ } while (0) PRETTY_FORMAT(buf, ", delay=", delay); diff --git a/postfix/src/global/mail_params.c b/postfix/src/global/mail_params.c index bd7729bad..c2e160594 100644 --- a/postfix/src/global/mail_params.c +++ b/postfix/src/global/mail_params.c @@ -104,7 +104,7 @@ /* int var_strict_encoding; /* int var_verify_neg_cache; /* int var_oldlog_compat; -/* int var_delay_resolution; +/* int var_delay_max_res; /* /* void mail_params_init() /* @@ -299,7 +299,7 @@ int var_strict_8bit_body; int var_strict_encoding; int var_verify_neg_cache; int var_oldlog_compat; -int var_delay_resolution; +int var_delay_max_res; const char null_format_string[1] = ""; @@ -563,7 +563,7 @@ void mail_params_init() VAR_SMTP_TLS_LOGLEVEL, DEF_SMTP_TLS_LOGLEVEL, &var_smtp_tls_loglevel, 0, 0, VAR_TLS_DAEMON_RAND_BYTES, DEF_TLS_DAEMON_RAND_BYTES, &var_tls_daemon_rand_bytes, 1, 0, #endif - VAR_DELAY_RESOLUTION, DEF_DELAY_RESOLUTION, &var_delay_resolution, MIN_DELAY_RESOLUTION, MAX_DELAY_RESOLUTION, + VAR_DELAY_MAX_RES, DEF_DELAY_MAX_RES, &var_delay_max_res, MIN_DELAY_MAX_RES, MAX_DELAY_MAX_RES, 0, }; static CONFIG_TIME_TABLE time_defaults[] = { diff --git a/postfix/src/global/mail_params.h b/postfix/src/global/mail_params.h index bb895ea20..6b00c12ea 100644 --- a/postfix/src/global/mail_params.h +++ b/postfix/src/global/mail_params.h @@ -2389,13 +2389,13 @@ extern char *var_msg_strip_chars; extern bool var_frozen_delivered; /* - * Delay logging time resolution. + * Delay logging time roundup. */ -#define VAR_DELAY_RESOLUTION "delay_logging_time_resolution" -#define MAX_DELAY_RESOLUTION 100000 -#define DEF_DELAY_RESOLUTION 10000 -#define MIN_DELAY_RESOLUTION 1 -extern int var_delay_resolution; +#define VAR_DELAY_MAX_RES "delay_logging_resolution_limit" +#define MAX_DELAY_MAX_RES 6 +#define DEF_DELAY_MAX_RES 2 +#define MIN_DELAY_MAX_RES 0 +extern int var_delay_max_res; /* LICENSE /* .ad diff --git a/postfix/src/global/mail_queue.c b/postfix/src/global/mail_queue.c index 1b9f31611..86b4a88f2 100644 --- a/postfix/src/global/mail_queue.c +++ b/postfix/src/global/mail_queue.c @@ -6,9 +6,10 @@ /* SYNOPSIS /* #include /* -/* VSTREAM *mail_queue_enter(queue_name, mode) +/* VSTREAM *mail_queue_enter(queue_name, mode, tp) /* const char *queue_name; /* mode_t mode; +/* struct timeval *tp; /* /* VSTREAM *mail_queue_open(queue_name, queue_id, flags, mode) /* const char *queue_name; @@ -53,7 +54,9 @@ /* id is the file base name, see VSTREAM_PATH(). Queue ids are /* relatively short strings and are recycled in the course of time. /* The only guarantee given is that on a given machine, no two queue -/* entries will have the same queue ID at the same time. +/* entries will have the same queue ID at the same time. The tp +/* argument, if not a null pointer, receives the time stamp that +/* corresponds with the queue ID. /* /* mail_queue_open() opens the named queue file. The \fIflags\fR /* and \fImode\fR arguments are as with open(2). The result is a @@ -304,7 +307,8 @@ int mail_queue_id_ok(const char *queue_id) /* mail_queue_enter - make mail queue entry with locally-unique name */ -VSTREAM *mail_queue_enter(const char *queue_name, mode_t mode) +VSTREAM *mail_queue_enter(const char *queue_name, mode_t mode, + struct timeval * tp) { char *myname = "mail_queue_enter"; static VSTRING *id_buf; @@ -326,7 +330,8 @@ VSTREAM *mail_queue_enter(const char *queue_name, mode_t mode) path_buf = vstring_alloc(10); temp_path = vstring_alloc(100); } - GETTIMEOFDAY(&tv); + if (tp == 0) + tp = &tv; /* * Create a file with a temporary name that does not collide. The process @@ -338,15 +343,13 @@ VSTREAM *mail_queue_enter(const char *queue_name, mode_t mode) * If someone is racing against us, try to win. */ for (;;) { + GETTIMEOFDAY(tp); vstring_sprintf(temp_path, "%s/%d.%d", queue_name, - (int) tv.tv_usec, pid); + (int) tp->tv_usec, pid); if ((fd = open(STR(temp_path), O_RDWR | O_CREAT | O_EXCL, mode)) >= 0) break; - if (errno == EEXIST || errno == EISDIR) { - if ((int) ++tv.tv_usec < 0) - tv.tv_usec = 0; + if (errno == EEXIST || errno == EISDIR) continue; - } msg_warn("%s: create file %s: %m", myname, STR(temp_path)); sleep(10); } @@ -364,7 +367,6 @@ VSTREAM *mail_queue_enter(const char *queue_name, mode_t mode) * If someone is racing against us, try to win. */ file_id = get_file_id(fd); - GETTIMEOFDAY(&tv); /* * XXX Some systems seem to have clocks that correlate with process @@ -374,22 +376,13 @@ VSTREAM *mail_queue_enter(const char *queue_name, mode_t mode) * prevents multiple messages from getting the same Message-ID value. */ for (count = 0;; count++) { - vstring_sprintf(id_buf, "%05X%s", (int) tv.tv_usec, file_id); + GETTIMEOFDAY(tp); + vstring_sprintf(id_buf, "%05X%s", (int) tp->tv_usec, file_id); mail_queue_path(path_buf, queue_name, STR(id_buf)); -#if 0 - if (access(STR(path_buf), X_OK) == 0) { /* collision. */ - if ((int) ++tv.tv_usec < 0) - tv.tv_usec = 0; - continue; - } -#endif if (sane_rename(STR(temp_path), STR(path_buf)) == 0) /* success */ break; - if (errno == EPERM || errno == EISDIR) {/* collision. weird. */ - if ((int) ++tv.tv_usec < 0) - tv.tv_usec = 0; + if (errno == EPERM || errno == EISDIR) /* collision. weird. */ continue; - } if (errno != ENOENT || mail_queue_mkdirs(STR(path_buf)) < 0) { msg_warn("%s: rename %s to %s: %m", myname, STR(temp_path), STR(path_buf)); diff --git a/postfix/src/global/mail_queue.h b/postfix/src/global/mail_queue.h index 19c04b7b8..8c4e3b898 100644 --- a/postfix/src/global/mail_queue.h +++ b/postfix/src/global/mail_queue.h @@ -11,6 +11,11 @@ /* DESCRIPTION /* .nf + /* + * System library. + */ +#include + /* * Utility library. */ @@ -37,7 +42,7 @@ #define MAIL_QUEUE_STAT_READY (S_IRUSR | S_IWUSR | S_IXUSR) #define MAIL_QUEUE_STAT_CORRUPT (S_IRUSR) -extern struct VSTREAM *mail_queue_enter(const char *, mode_t); +extern struct VSTREAM *mail_queue_enter(const char *, mode_t, struct timeval *); extern struct VSTREAM *mail_queue_open(const char *, const char *, int, mode_t); extern int mail_queue_rename(const char *, const char *, const char *); extern int mail_queue_remove(const char *, const char *); diff --git a/postfix/src/global/mail_stream.c b/postfix/src/global/mail_stream.c index 5ac392b1a..1039bddc5 100644 --- a/postfix/src/global/mail_stream.c +++ b/postfix/src/global/mail_stream.c @@ -8,8 +8,9 @@ /* /* typedef struct { /* .in +4 -/* VSTREAM *stream; -/* char *id; +/* VSTREAM *stream; /* read/write stream */ +/* char *id; /* queue ID */ +/* struct timeval ctime; /* create time */ /* private members... /* .in -4 /* } MAIL_STREAM; @@ -296,10 +297,11 @@ int mail_stream_finish(MAIL_STREAM *info, VSTRING *why) MAIL_STREAM *mail_stream_file(const char *queue, const char *class, const char *service, int mode) { + struct timeval tv; MAIL_STREAM *info; VSTREAM *stream; - stream = mail_queue_enter(queue, 0600 | mode); + stream = mail_queue_enter(queue, 0600 | mode, &tv); if (msg_verbose) msg_info("open %s", VSTREAM_PATH(stream)); @@ -312,6 +314,7 @@ MAIL_STREAM *mail_stream_file(const char *queue, const char *class, info->class = mystrdup(class); info->service = mystrdup(service); info->mode = mode; + info->ctime = tv; return (info); } diff --git a/postfix/src/global/mail_stream.h b/postfix/src/global/mail_stream.h index 455b65011..cee04bc86 100644 --- a/postfix/src/global/mail_stream.h +++ b/postfix/src/global/mail_stream.h @@ -11,6 +11,11 @@ /* DESCRIPTION /* .nf + /* + * System library. + */ +#include + /* * Utility library. */ @@ -34,6 +39,7 @@ struct MAIL_STREAM { char *class; /* trigger class */ char *service; /* trigger service */ int mode; /* additional permissions */ + struct timeval ctime; /* creation time */ }; #define MAIL_STREAM_CTL_END 0 /* Terminator */ diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index cd57710e6..a020efc61 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,7 +20,7 @@ * Patches change both the patchlevel and the release date. Snapshots have no * patchlevel; they change the release date only. */ -#define MAIL_RELEASE_DATE "20051106" +#define MAIL_RELEASE_DATE "20051108" #define MAIL_VERSION_NUMBER "2.3" #ifdef SNAPSHOT diff --git a/postfix/src/lmtp/lmtp.c b/postfix/src/lmtp/lmtp.c index c18ab7715..fc252aebd 100644 --- a/postfix/src/lmtp/lmtp.c +++ b/postfix/src/lmtp/lmtp.c @@ -174,9 +174,9 @@ /* .IP "\fBdaemon_timeout (18000s)\fR" /* How much time a Postfix daemon process may take to handle a /* request before it is terminated by a built-in watchdog timer. -/* .IP "\fBdelay_logging_time_resolution (10000)\fR" -/* The time resolution (microseconds) of the sub-second delay -/* values that are logged for subsequent message delivery stages. +/* .IP "\fBdelay_logging_resolution_limit (2)\fR" +/* The maximal number of digits after the decimal point when logging +/* sub-second delay values. /* .IP "\fBdisable_dns_lookups (no)\fR" /* Disable DNS lookups in the Postfix SMTP and LMTP clients. /* .IP "\fBipc_timeout (3600s)\fR" diff --git a/postfix/src/local/local.c b/postfix/src/local/local.c index e3b8373d7..5de53e485 100644 --- a/postfix/src/local/local.c +++ b/postfix/src/local/local.c @@ -469,9 +469,9 @@ /* .IP "\fBdaemon_timeout (18000s)\fR" /* How much time a Postfix daemon process may take to handle a /* request before it is terminated by a built-in watchdog timer. -/* .IP "\fBdelay_logging_time_resolution (10000)\fR" -/* The time resolution (microseconds) of the sub-second delay -/* values that are logged for subsequent message delivery stages. +/* .IP "\fBdelay_logging_resolution_limit (2)\fR" +/* The maximal number of digits after the decimal point when logging +/* sub-second delay values. /* .IP "\fBexport_environment (see 'postconf -d' output)\fR" /* The list of environment variables that a Postfix process will export /* to non-Postfix processes. diff --git a/postfix/src/oqmgr/qmgr.c b/postfix/src/oqmgr/qmgr.c index 5e16f7e79..e91947b8d 100644 --- a/postfix/src/oqmgr/qmgr.c +++ b/postfix/src/oqmgr/qmgr.c @@ -221,9 +221,9 @@ /* .IP "\fBdefer_transports (empty)\fR" /* The names of message delivery transports that should not deliver mail /* unless someone issues "\fBsendmail -q\fR" or equivalent. -/* .IP "\fBdelay_logging_time_resolution (10000)\fR" -/* The time resolution (microseconds) of the sub-second delay -/* values that are logged for subsequent message delivery stages. +/* .IP "\fBdelay_logging_resolution_limit (2)\fR" +/* The maximal number of digits after the decimal point when logging +/* sub-second delay values. /* .IP "\fBhelpful_warnings (yes)\fR" /* Log warnings about problematic configuration settings, and provide /* helpful suggestions. diff --git a/postfix/src/pipe/pipe.c b/postfix/src/pipe/pipe.c index 8ea5e1695..e365a3e9d 100644 --- a/postfix/src/pipe/pipe.c +++ b/postfix/src/pipe/pipe.c @@ -298,9 +298,9 @@ /* .IP "\fBdaemon_timeout (18000s)\fR" /* How much time a Postfix daemon process may take to handle a /* request before it is terminated by a built-in watchdog timer. -/* .IP "\fBdelay_logging_time_resolution (10000)\fR" -/* The time resolution (microseconds) of the sub-second delay -/* values that are logged for subsequent message delivery stages. +/* .IP "\fBdelay_logging_resolution_limit (2)\fR" +/* The maximal number of digits after the decimal point when logging +/* sub-second delay values. /* .IP "\fBexport_environment (see 'postconf -d' output)\fR" /* The list of environment variables that a Postfix process will export /* to non-Postfix processes. diff --git a/postfix/src/qmgr/qmgr.c b/postfix/src/qmgr/qmgr.c index e3efb58d9..bbd941c19 100644 --- a/postfix/src/qmgr/qmgr.c +++ b/postfix/src/qmgr/qmgr.c @@ -256,9 +256,9 @@ /* .IP "\fBdefer_transports (empty)\fR" /* The names of message delivery transports that should not deliver mail /* unless someone issues "\fBsendmail -q\fR" or equivalent. -/* .IP "\fBdelay_logging_time_resolution (10000)\fR" -/* The time resolution (microseconds) of the sub-second delay -/* values that are logged for subsequent message delivery stages. +/* .IP "\fBdelay_logging_resolution_limit (2)\fR" +/* The maximal number of digits after the decimal point when logging +/* sub-second delay values. /* .IP "\fBhelpful_warnings (yes)\fR" /* Log warnings about problematic configuration settings, and provide /* helpful suggestions. diff --git a/postfix/src/smtp/smtp.c b/postfix/src/smtp/smtp.c index 377d9cf13..2b044626f 100644 --- a/postfix/src/smtp/smtp.c +++ b/postfix/src/smtp/smtp.c @@ -308,9 +308,9 @@ /* .IP "\fBdaemon_timeout (18000s)\fR" /* How much time a Postfix daemon process may take to handle a /* request before it is terminated by a built-in watchdog timer. -/* .IP "\fBdelay_logging_time_resolution (10000)\fR" -/* The time resolution (microseconds) of the sub-second delay -/* values that are logged for subsequent message delivery stages. +/* .IP "\fBdelay_logging_resolution_limit (2)\fR" +/* The maximal number of digits after the decimal point when logging +/* sub-second delay values. /* .IP "\fBdisable_dns_lookups (no)\fR" /* Disable DNS lookups in the Postfix SMTP and LMTP clients. /* .IP "\fBfallback_relay (empty)\fR" diff --git a/postfix/src/util/Makefile.in b/postfix/src/util/Makefile.in index 8010a2051..f337b4502 100644 --- a/postfix/src/util/Makefile.in +++ b/postfix/src/util/Makefile.in @@ -29,7 +29,7 @@ SRCS = alldig.c allprint.c argv.c argv_split.c attr_clnt.c attr_print0.c \ unix_recv_fd.c unix_send_fd.c unix_trigger.c unsafe.c uppercase.c \ username.c valid_hostname.c vbuf.c vbuf_print.c vstream.c \ vstream_popen.c vstring.c vstring_vstream.c watchdog.c writable.c \ - write_buf.c write_wait.c sane_basename.c + write_buf.c write_wait.c sane_basename.c format_tv.c OBJS = alldig.o allprint.o argv.o argv_split.o attr_clnt.o attr_print0.o \ attr_print64.o attr_print_plain.o attr_scan0.o attr_scan64.o \ attr_scan_plain.o auto_clnt.o base64_code.o basename.o binhash.o \ @@ -60,7 +60,7 @@ OBJS = alldig.o allprint.o argv.o argv_split.o attr_clnt.o attr_print0.o \ unix_recv_fd.o unix_send_fd.o unix_trigger.o unsafe.o uppercase.o \ username.o valid_hostname.o vbuf.o vbuf_print.o vstream.o \ vstream_popen.o vstring.o vstring_vstream.o watchdog.o writable.o \ - write_buf.o write_wait.o sane_basename.o + write_buf.o write_wait.o sane_basename.o format_tv.o HDRS = argv.h attr.h attr_clnt.h auto_clnt.h base64_code.h binhash.h \ chroot_uid.h cidr_match.h clean_env.h connect.h ctable.h dict.h \ dict_cdb.h dict_cidr.h dict_db.h dict_dbm.h dict_env.h dict_ht.h \ @@ -79,7 +79,7 @@ HDRS = argv.h attr.h attr_clnt.h auto_clnt.h base64_code.h binhash.h \ sigdelay.h sock_addr.h spawn_command.h split_at.h stat_as.h \ stringops.h sys_defs.h timed_connect.h timed_wait.h trigger.h \ username.h valid_hostname.h vbuf.h vbuf_print.h vstream.h vstring.h \ - vstring_vstream.h watchdog.h + vstring_vstream.h watchdog.h format_tv.h TESTSRC = fifo_open.c fifo_rdwr_bug.c fifo_rdonly_bug.c select_bug.c \ stream_test.c dup2_pass_on_exec.c DEFS = -I. -D$(SYSTYPE) @@ -96,7 +96,7 @@ TESTPROG= dict_open dup2_pass_on_exec events exec_command fifo_open \ inet_addr_list attr_print64 attr_scan64 base64_code attr_print0 \ attr_scan0 host_port attr_scan_plain attr_print_plain htable \ unix_recv_fd unix_send_fd stream_recv_fd stream_send_fd hex_code \ - myaddrinfo myaddrinfo4 inet_proto sane_basename + myaddrinfo myaddrinfo4 inet_proto sane_basename format_tv LIB_DIR = ../../lib INC_DIR = ../../include @@ -401,11 +401,16 @@ gcctest: gccw.c gccw.ref diff gccw.ref gccw.tmp rm -f gccw.o gccw.tmp +format_tv: $(LIB) + mv $@.o junk + $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS) + mv junk $@.o + tests: valid_hostname_test mac_expand_test dict_test unescape_test \ hex_quote_test ctable_test inet_addr_list_test base64_code_test \ attr_scan64_test attr_scan0_test dict_pcre_test host_port_test \ dict_cidr_test attr_scan_plain_test htable_test hex_code_test \ - myaddrinfo_test + myaddrinfo_test format_tv_test valid_hostname_test: valid_hostname valid_hostname.in valid_hostname.ref ./valid_hostname valid_hostname.tmp @@ -512,6 +517,11 @@ myaddrinfo4_test: myaddrinfo4 myaddrinfo4.ref myaddrinfo4.ref2 diff myaddrinfo4.ref2 myaddrinfo4.tmp rm -f myaddrinfo4.tmp +format_tv_test: format_tv format_tv.in format_tv.ref + ./format_tv format_tv.tmp + diff format_tv.ref format_tv.tmp + rm -f format_tv.tmp + depend: $(MAKES) (sed '1,/^# do not edit/!d' Makefile.in; \ set -e; for i in [a-z][a-z0-9]*.c; do \ @@ -966,6 +976,12 @@ find_inet.o: stringops.h find_inet.o: sys_defs.h find_inet.o: vbuf.h find_inet.o: vstring.h +format_tv.o: format_tv.c +format_tv.o: format_tv.h +format_tv.o: msg.h +format_tv.o: sys_defs.h +format_tv.o: vbuf.h +format_tv.o: vstring.h fsspace.o: fsspace.c fsspace.o: fsspace.h fsspace.o: msg.h diff --git a/postfix/src/util/format_tv.c b/postfix/src/util/format_tv.c new file mode 100644 index 000000000..2c54c4eac --- /dev/null +++ b/postfix/src/util/format_tv.c @@ -0,0 +1,156 @@ +/*++ +/* NAME +/* format_tv 3 +/* SUMMARY +/* format time value with limited precision +/* SYNOPSIS +/* #include +/* +/* VSTRING *format_tv(buffer, sec, usec, width, max_pos) +/* VSTRING *buffer; +/* int sec; +/* int usec; +/* int width; +/* int max_pos; +/* DESCRIPTION +/* format_tv() formats the specified time while suppressing +/* irrelevant digits in the output. Large numbers are always +/* rounded up to an integral number of seconds. Small numbers +/* are produced with a limited number of digits, provided that +/* those digits don't exceed the limit on the number of positions +/* after the decimal point. Trailing zeros are always omitted +/* from the output. +/* +/* Arguments: +/* .IP buffer +/* Buffer to which the result is appended. +/* .IP sec +/* The seconds portion of the time value. +/* .IP usec +/* The microseconds portion of the time value. +/* .IP width +/* The maximal number of digits to produce when formatting +/* small numbers. Trailing nulls are always omitted. Specify +/* a number in the range 1..6. +/* .IP max_pos +/* The maximal number of positions after the decimal point. +/* Specify a number in the range 0..6. +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +#include + +/* Utility library. */ + +#include +#include + +/* Application-specific. */ + +#define MILLION 1000000 + +/* format_tv - print time with limited precision */ + +VSTRING *format_tv(VSTRING *buf, int sec, int usec, int width, int max) +{ + static int pow10[] = {1, 10, 100, 1000, 10000, 100000, 1000000}; + int n; + int rem; + int wid; + int ures; + + /* + * Sanity check. + */ + if (max < 0 || max > 6) + msg_panic("format_tv: bad max decimal count %d", max); + if (sec < 0 || usec < 0 || usec > MILLION) + msg_panic("format_tv: bad time %ds %dus", sec, usec); + if (width < 1 || width > 6) + msg_panic("format_tv: bad width %d", width); + ures = MILLION / pow10[max]; + wid = pow10[width]; + + /* + * Adjust the resolution to suppress irrelevant digits. + */ + if (ures < MILLION) { + if (sec > 0) { + for (n = 1; sec >= n && n <= wid / 10; n *= 10) + /* void */ ; + ures = (MILLION / wid) * n; + } else { + while (usec >= wid * ures) + ures *= 10; + } + } + + /* + * Round up the number if necessary. Leave thrash below the resolution. + */ + if (ures > 1) { + usec += ures / 2; + if (usec >= MILLION) { + sec += 1; + usec -= MILLION; + } + } + + /* + * Format the number. Truncate thrash below the resolution. + */ + vstring_sprintf_append(buf, "%d", sec); + if (usec >= ures) { + VSTRING_ADDCH(buf, '.'); + for (rem = usec, n = MILLION / 10; rem >= ures && n > 0; n /= 10) { + VSTRING_ADDCH(buf, "0123456789"[rem / n]); + rem %= n; + } + } + VSTRING_TERMINATE(buf); + return (buf); +} + +#ifdef TEST + +#include +#include +#include + +int main(int argc, char **argv) +{ + VSTRING *in = vstring_alloc(10); + VSTRING *out = vstring_alloc(10); + double tval; + int sec; + int usec; + int width; + int max_pos; + + while (vstring_get_nonl(in, VSTREAM_IN) > 0) { + vstream_printf(">> %s\n", vstring_str(in)); + if (vstring_str(in)[0] == 0 || vstring_str(in)[0] == '#') + continue; + if (sscanf(vstring_str(in), "%lf %d %d", &tval, &width, &max_pos) != 3) + msg_fatal("bad input: %s", vstring_str(in)); + sec = (int) tval; /* raw seconds */ + usec = (tval - sec) * MILLION; /* raw microseconds */ + VSTRING_RESET(out); + format_tv(out, sec, usec, width, max_pos); + vstream_printf("%s\n", vstring_str(out)); + vstream_fflush(VSTREAM_OUT); + } + vstring_free(in); + vstring_free(out); + return (0); +} + +#endif diff --git a/postfix/src/util/format_tv.h b/postfix/src/util/format_tv.h new file mode 100644 index 000000000..e62a8618c --- /dev/null +++ b/postfix/src/util/format_tv.h @@ -0,0 +1,35 @@ +#ifndef _FORMAT_TV_H_INCLUDED_ +#define _FORMAT_TV_H_INCLUDED_ + +/*++ +/* NAME +/* format_tv 3h +/* SUMMARY +/* format time with limited precision +/* SYNOPSIS +/* #include +/* DESCRIPTION +/* .nf + + /* + * Utility library. + */ +#include + + /* + * External interface. + */ +extern VSTRING *format_tv(VSTRING *, int, int, int, int); + +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +#endif diff --git a/postfix/src/util/format_tv.in b/postfix/src/util/format_tv.in new file mode 100644 index 000000000..7b6bec5f2 --- /dev/null +++ b/postfix/src/util/format_tv.in @@ -0,0 +1,68 @@ +# Three digits in, 2/6 digits out, rounding down. +1110 2 6 +111 2 6 +11.1 2 6 +1.11 2 6 +0.111 2 6 +0.0111 2 6 +0.00111 2 6 +0.000111 2 6 +0.000011 2 6 + +# One digit in. Must not produce spurious digits or trailing nulls. + +1000 2 6 +100 2 6 +10 2 6 +1 2 6 +0.1 2 6 +0.01 2 6 +0.001 2 6 +0.0001 2 6 +0.00001 2 6 +0.000001 2 6 + +# Three digits in, 2/6 digits out, rounding up. + +996 2 6 +99.6 2 6 +9.96 2 6 +.996 2 6 +.0996 2 6 +.00996 2 6 +.000996 2 6 + +# Three digits in, 1/6 digits out, rounding down. + +1110 1 6 +111 1 6 +11.1 1 6 +1.11 1 6 +0.111 1 6 +0.0111 1 6 +0.00111 1 6 +0.000111 1 6 +0.000011 1 6 + +# One digit in. Must not produce trailing nulls. + +1000 1 6 +100 1 6 +10 1 6 +1 1 6 +0.1 1 6 +0.01 1 6 +0.001 1 6 +0.0001 1 6 +0.00001 1 6 +0.000001 1 6 + +# Three digits in, 1/6 digits out, rounding up. + +996 1 6 +99.6 1 6 +9.96 1 6 +.996 1 6 +.0996 1 6 +.00996 1 6 +.000996 1 6 diff --git a/postfix/src/util/format_tv.ref b/postfix/src/util/format_tv.ref new file mode 100644 index 000000000..2068796ee --- /dev/null +++ b/postfix/src/util/format_tv.ref @@ -0,0 +1,120 @@ +>> # Three digits in, 2/6 digits out, rounding down. +>> 1110 2 6 +1110 +>> 111 2 6 +111 +>> 11.1 2 6 +11 +>> 1.11 2 6 +1.1 +>> 0.111 2 6 +0.11 +>> 0.0111 2 6 +0.011 +>> 0.00111 2 6 +0.0011 +>> 0.000111 2 6 +0.00011 +>> 0.000011 2 6 +0.000011 +>> +>> # One digit in. Must not produce spurious digits or trailing nulls. +>> +>> 1000 2 6 +1000 +>> 100 2 6 +100 +>> 10 2 6 +10 +>> 1 2 6 +1 +>> 0.1 2 6 +0.1 +>> 0.01 2 6 +0.01 +>> 0.001 2 6 +0.001 +>> 0.0001 2 6 +0.0001 +>> 0.00001 2 6 +0.00001 +>> 0.000001 2 6 +0.000001 +>> +>> # Three digits in, 2/6 digits out, rounding up. +>> +>> 996 2 6 +996 +>> 99.6 2 6 +100 +>> 9.96 2 6 +10 +>> .996 2 6 +1 +>> .0996 2 6 +0.1 +>> .00996 2 6 +0.01 +>> .000996 2 6 +0.001 +>> +>> # Three digits in, 1/6 digits out, rounding down. +>> +>> 1110 1 6 +1110 +>> 111 1 6 +111 +>> 11.1 1 6 +11 +>> 1.11 1 6 +1 +>> 0.111 1 6 +0.1 +>> 0.0111 1 6 +0.01 +>> 0.00111 1 6 +0.001 +>> 0.000111 1 6 +0.0001 +>> 0.000011 1 6 +0.00001 +>> +>> # One digit in. Must not produce trailing nulls. +>> +>> 1000 1 6 +1000 +>> 100 1 6 +100 +>> 10 1 6 +10 +>> 1 1 6 +1 +>> 0.1 1 6 +0.1 +>> 0.01 1 6 +0.01 +>> 0.001 1 6 +0.001 +>> 0.0001 1 6 +0.0001 +>> 0.00001 1 6 +0.00001 +>> 0.000001 1 6 +0.000001 +>> +>> # Three digits in, 1/6 digits out, rounding up. +>> +>> 996 1 6 +996 +>> 99.6 1 6 +100 +>> 9.96 1 6 +10 +>> .996 1 6 +1 +>> .0996 1 6 +0.1 +>> .00996 1 6 +0.01 +>> .000996 1 6 +0.001 diff --git a/postfix/src/util/vstream.c b/postfix/src/util/vstream.c index 416ec8f09..2fb5a291a 100644 --- a/postfix/src/util/vstream.c +++ b/postfix/src/util/vstream.c @@ -112,6 +112,9 @@ /* /* time_t vstream_ftime(stream) /* VSTREAM *stream; +/* +/* struct timeval vstream_ftimeval(stream) +/* VSTREAM *stream; /* DESCRIPTION /* The \fIvstream\fR module implements light-weight buffered I/O /* similar to the standard I/O routines. @@ -306,6 +309,9 @@ /* fill operation, or the last buffer flush operation for the specified /* stream. This information is maintained only when stream timeouts are /* enabled. +/* +/* vstream_ftimeval() is like vstream_ftime() but returns more +/* detail. /* DIAGNOSTICS /* Panics: interface violations. Fatal errors: out of memory. /* SEE ALSO @@ -559,7 +565,7 @@ static int vstream_fflush_some(VSTREAM *stream, ssize_t to_flush) return (VSTREAM_EOF); } if (stream->timeout) - stream->iotime = time((time_t *) 0); + GETTIMEOFDAY(&stream->iotime); if (msg_verbose > 2 && stream != VSTREAM_ERR && n != to_flush) msg_info("%s: %d flushed %ld/%ld", myname, stream->fd, (long) n, (long) to_flush); @@ -695,7 +701,7 @@ static int vstream_buf_get_ready(VBUF *bp) return (VSTREAM_EOF); default: if (stream->timeout) - stream->iotime = time((time_t *) 0); + GETTIMEOFDAY(&stream->iotime); if (msg_verbose > 2) msg_info("%s: fd %d got %ld", myname, stream->fd, (long) n); bp->cnt = -n; @@ -996,7 +1002,7 @@ VSTREAM *vstream_fdopen(int fd, int flags) stream->timeout = 0; stream->context = 0; stream->jbuf = 0; - stream->iotime = 0; + stream->iotime.tv_sec = stream->iotime.tv_usec = 0; return (stream); } @@ -1168,7 +1174,7 @@ void vstream_control(VSTREAM *stream, int name,...) break; case VSTREAM_CTL_TIMEOUT: if (stream->timeout == 0) - stream->iotime = time((time_t *) 0); + GETTIMEOFDAY(&stream->iotime); stream->timeout = va_arg(ap, int); break; case VSTREAM_CTL_EXCEPT: diff --git a/postfix/src/util/vstream.h b/postfix/src/util/vstream.h index 17d05bf7f..7e71cc215 100644 --- a/postfix/src/util/vstream.h +++ b/postfix/src/util/vstream.h @@ -14,6 +14,7 @@ /* * System library. */ +#include #include #include #include @@ -48,7 +49,7 @@ typedef struct VSTREAM { VSTREAM_WAITPID_FN waitpid_fn; /* vstream_popen/close() */ int timeout; /* read/write timout */ jmp_buf *jbuf; /* exception handling */ - time_t iotime; /* time of last fill/flush */ + struct timeval iotime; /* time of last fill/flush */ } VSTREAM; extern VSTREAM vstream_fstd[]; /* pre-defined streams */ @@ -99,7 +100,8 @@ extern int vstream_fdclose(VSTREAM *); #define vstream_ftimeout(vp) vbuf_timeout(&(vp)->buf) #define vstream_clearerr(vp) vbuf_clearerr(&(vp)->buf) #define VSTREAM_PATH(vp) ((vp)->path ? (vp)->path : "unknown_stream") -#define vstream_ftime(vp) ((vp)->iotime) +#define vstream_ftime(vp) ((time_t) ((vp)->iotime.tv_sec)) +#define vstream_ftimeval(vp) ((vp)->iotime) extern void vstream_control(VSTREAM *, int,...); diff --git a/postfix/src/virtual/virtual.c b/postfix/src/virtual/virtual.c index 928a91006..fd5df201d 100644 --- a/postfix/src/virtual/virtual.c +++ b/postfix/src/virtual/virtual.c @@ -211,9 +211,9 @@ /* .IP "\fBdaemon_timeout (18000s)\fR" /* How much time a Postfix daemon process may take to handle a /* request before it is terminated by a built-in watchdog timer. -/* .IP "\fBdelay_logging_time_resolution (10000)\fR" -/* The time resolution (microseconds) of the sub-second delay -/* values that are logged for subsequent message delivery stages. +/* .IP "\fBdelay_logging_resolution_limit (2)\fR" +/* The maximal number of digits after the decimal point when logging +/* sub-second delay values. /* .IP "\fBipc_timeout (3600s)\fR" /* The time limit for sending or receiving information over an internal /* communication channel. -- 2.47.3