diff --git a/postfix/HISTORY b/postfix/HISTORY
index 4f0d372e2..0b6cc7850 100644
--- a/postfix/HISTORY
+++ b/postfix/HISTORY
@@ -9583,12 +9583,12 @@ Apologies for any names omitted.
recvmsg(). Workaround is to insert an intervening read
(write) operation. Presumably, LINUX 2.4 is confusing the
data and file descriptor. Lucky Ralf Hildebrandt. Files:
- util/sys_defs.h, global/scache_clnt,c, scache/scache.c.
+ util/sys_defs.h, global/scache_clnt.c, scache/scache.c.
20040723
Bug? Safety? spawn(8) did not reject a user with the -1
- UID value, so the command was running as root. Files:
+ UID value, so the command could run as root. Files:
util/spawn_command.c, src/util/spawn.c.
User interface: parameter smtp_connection_cache_domains
@@ -9599,6 +9599,18 @@ Apologies for any names omitted.
Bugfix: "421 Timeout exceeded" wasn't guarded by setjmp().
Victor Duchovni, Morgan Stanley. File: smtpd/smtpd.c.
+20040729
+
+ Feature: enable SMTP session caching temporarily while a
+ site has a high volume of mail in the active queue.
+ Parameter: smtp_connection_cache_on_demand (default:
+ yes). Files: smtp/smtp_connect.c, *qmgr/qmgr_entry.c,
+ *qmgr/qmgr_queue.c, *qmgr/qmgr_deliver.c.
+
+ Feature: smtp-source -N option to generate unique recipient
+ addresses for (trivial-rewrite) stress testing. Victor
+ Duchovni, Morgan Stanley. File: smtpstone/smtp-source.c.
+
Open problems:
Low: update events.c so that 1-second timer requests do
diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES
index 0f8acd52c..4a4ce9f62 100644
--- a/postfix/RELEASE_NOTES
+++ b/postfix/RELEASE_NOTES
@@ -7,14 +7,30 @@ snapshot release). Patches are issued for the official release
and change the patchlevel and the release date. Patches are never
issued for snapshot releases.
+Incompatible changes with snapshot Postfix-2.2-20040729
+=======================================================
+
+SMTP session caching is enabled temporarily when a destination has
+a high volume of mail in the active queue. To disable, specify
+"smtp_connection_cache_on_demand = no".
+
+Major changes with snapshot Postfix-2.2-20040729
+================================================
+
+Opportunistic SMTP session caching. When a destination has a high
+volume of mail in the active queue, SMTP session caching is enabled
+temporarily. This is controlled with a new configuration parameter
+"smtp_connection_cache_on_demand" (default: yes).
+
Incompatible changes with snapshot Postfix-2.2-20040723
=======================================================
-Session caching is enabled with smtp_session_cache_destinations,
-and requires "bare" domain names without "[]" or TCP port. This
-eliminates a syntax conflict between host:port and maptype:mapname,
-and simplifies the user interface, at the cost of a minor loss of
-control over what sessions are cached.
+Permanent SMTP session caching is now enabled with the
+smtp_session_cache_destinations parameter. This requires "bare"
+domain names without "[]" or TCP port. The change eliminates a
+syntax conflict between host:port and maptype:mapname, and simplifies
+the user interface, at the cost of a minor loss of control over
+what sessions are cached.
Major changes with snapshot Postfix-2.2-20040721
================================================
@@ -38,10 +54,10 @@ The default SMTP/LMTP timeouts for sending RSET are reduced to 20s.
Major changes with snapshot Postfix-2.2-20040720
================================================
-Selective SMTP session caching. Instead of disconnecting immediately
-after a mail transaction, the SMTP client can save the open session
-to a session cache daemon, so that any SMTP client process can use
-that session for another mail transaction.
+Selective permanent SMTP session caching. Instead of disconnecting
+immediately after a mail transaction, the SMTP client can save the
+open session to a session cache daemon, so that any SMTP client
+process can use that session for another mail transaction.
This feature introduces the scache (session cache) server, which
is added to your master.cf file when you upgrade Postfix.
diff --git a/postfix/html/postconf.5.html b/postfix/html/postconf.5.html
index 235e3d1a3..59035717e 100644
--- a/postfix/html/postconf.5.html
+++ b/postfix/html/postconf.5.html
@@ -5169,10 +5169,10 @@ The default time unit is s (seconds).
smtp_connection_cache_reuse_limit
diff --git a/postfix/html/smtp-source.1.html b/postfix/html/smtp-source.1.html
index 18ada81a2..ca2477b07 100644
--- a/postfix/html/smtp-source.1.html
+++ b/postfix/html/smtp-source.1.html
@@ -52,8 +52,15 @@ SMTP-SOURCE(1) SMTP-SOURCE(1)
-m message_count
Send the specified number of messages (default: 1).
+ -N Prepend a non-repeating sequence number to each
+ recipient address. This avoids the artificial 100%
+ hit rate in the resolve and rewrite client caches
+ and exercises the trivial-rewrite daemon, better
+ approximating Postfix performance under real-life
+ work-loads.
+
-r recipient_count
- Send the specified number of recipients per trans-
+ Send the specified number of recipients per trans-
action (default: 1). Recipient names are generated
by prepending a number to the recipient address.
@@ -62,15 +69,15 @@ SMTP-SOURCE(1) SMTP-SOURCE(1)
lel (default: 1).
-S subject
- Send mail with the named subject line (default:
+ Send mail with the named subject line (default:
none).
- -t to Use the specified recipient address (default:
+ -t to Use the specified recipient address (default:
<foo@myhostname>).
-R interval
Wait for a random period of time 0 <= n <= interval
- between messages. Suspending one thread does not
+ between messages. Suspending one thread does not
affect other delivery threads.
-w interval
@@ -78,7 +85,7 @@ SMTP-SOURCE(1) SMTP-SOURCE(1)
thread does not affect other delivery threads.
[inet:]host[:port]
- Connect via TCP to host host, port port. The
+ Connect via TCP to host host, port port. The
default port is smtp.
unix:pathname
@@ -91,7 +98,7 @@ SMTP-SOURCE(1) SMTP-SOURCE(1)
smtp-sink(1), SMTP/LMTP message dump
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 8fd7b06a9..808664687 100644
--- a/postfix/html/smtp.8.html
+++ b/postfix/html/smtp.8.html
@@ -37,11 +37,16 @@ SMTP(8) SMTP(8)
After a successful mail transaction, a session may be
saved to the scache(8) session cache server, so that it
may be used by any SMTP client for a subsequent transac-
- tion. Session caching is disabled by default.
+ tion.
+
+ By default, session caching is enabled temporarily for
+ destinations that have a high volume of mail in the active
+ queue. Session caching can be enabled permanently for spe-
+ cific destinations.
SECURITY
The SMTP client is moderately security-sensitive. It talks
- to SMTP servers and to DNS servers on the network. The
+ to SMTP servers and to DNS servers on the network. The
SMTP client can be run chrooted at fixed low privilege.
STANDARDS
@@ -57,30 +62,30 @@ SMTP(8) SMTP(8)
RFC 2920 (SMTP Pipelining)
DIAGNOSTICS
- Problems and transactions are logged to syslogd(8). Cor-
- rupted message files are marked so that the queue manager
+ Problems and transactions are logged to syslogd(8). Cor-
+ rupted message files are marked so that the queue manager
can move them to the corrupt queue for further inspection.
- Depending on the setting of the notify_classes parameter,
- the postmaster is notified of bounces, protocol problems,
+ Depending on the setting of the notify_classes parameter,
+ the postmaster is notified of bounces, protocol problems,
and of other trouble.
BUGS
SMTP session caching does not work with TLS. The necessary
- support for TLS object passivation and re-activation does
- not exist without closing the session, which defeats the
+ support for TLS object passivation and re-activation does
+ not exist without closing the session, which defeats the
purpose.
- SMTP session caching assumes that SASL credentials are
- valid for all destinations that map onto the same IP
+ SMTP session caching assumes that SASL credentials are
+ valid for all destinations that map onto the same IP
address and TCP port.
CONFIGURATION PARAMETERS
Changes to main.cf are picked up automatically, as smtp(8)
- processes run for only a limited amount of time. Use the
+ processes run for only a limited amount of time. Use the
command "postfix reload" to speed up a change.
- The text below provides only a parameter summary. See
+ The text below provides only a parameter summary. See
postconf(5) for more details including examples.
COMPATIBILITY CONTROLS
@@ -94,7 +99,7 @@ SMTP(8) SMTP(8)
Never send EHLO at the start of an SMTP session.
smtp_defer_if_no_mx_address_found (no)
- Defer mail delivery when no MX record resolves to
+ Defer mail delivery when no MX record resolves to
an IP address.
smtp_line_length_limit (990)
@@ -102,17 +107,17 @@ SMTP(8) SMTP(8)
that Postfix will send via SMTP.
smtp_pix_workaround_delay_time (10s)
- How long the Postfix SMTP client pauses before
+ How long the Postfix SMTP client pauses before
sending ".<CR><LF>" in order to work around the PIX
firewall "<CR><LF>.<CR><LF>" bug.
smtp_pix_workaround_threshold_time (500s)
- How long a message must be queued before the PIX
- firewall "<CR><LF>.<CR><LF>" bug workaround is
+ How long a message must be queued before the PIX
+ firewall "<CR><LF>.<CR><LF>" bug workaround is
turned on.
smtp_quote_rfc821_envelope (yes)
- Quote addresses in SMTP MAIL FROM and RCPT TO com-
+ Quote addresses in SMTP MAIL FROM and RCPT TO com-
mands as required by RFC 821.
smtp_skip_5xx_greeting (yes)
@@ -120,7 +125,7 @@ SMTP(8) SMTP(8)
(go away, do not try again later).
smtp_skip_quit_response (yes)
- Do not wait for the response to the SMTP QUIT com-
+ Do not wait for the response to the SMTP QUIT com-
mand.
Available in Postfix version 2.0 and earlier:
@@ -133,7 +138,7 @@ SMTP(8) SMTP(8)
Available in Postfix version 2.0 and later:
disable_mime_output_conversion (no)
- Disable the conversion of 8BITMIME format to 7BIT
+ Disable the conversion of 8BITMIME format to 7BIT
format.
mime_boundary_length_limit (2048)
@@ -148,43 +153,43 @@ SMTP(8) SMTP(8)
Available in Postfix version 2.1 and later:
smtp_send_xforward_command (no)
- Send the non-standard XFORWARD command when the
- Postfix SMTP server EHLO response announces XFOR-
+ Send the non-standard XFORWARD command when the
+ Postfix SMTP server EHLO response announces XFOR-
WARD support.
SASL AUTHENTICATION CONTROLS
smtp_sasl_auth_enable (no)
- Enable SASL authentication in the Postfix SMTP
+ Enable SASL authentication in the Postfix SMTP
client.
smtp_sasl_password_maps (empty)
- Optional SMTP client lookup tables with one user-
- name:password entry per remote hostname or domain.
+ Optional SMTP client lookup tables with one user-
+ name:password entry per remote hostname or domain.
smtp_sasl_security_options (noplaintext, noanonymous)
- What authentication mechanisms the Postfix SMTP
+ What authentication mechanisms the Postfix SMTP
client is allowed to use.
RESOURCE AND RATE CONTROLS
smtp_destination_concurrency_limit ($default_destina-
tion_concurrency_limit)
- The maximal number of parallel deliveries to the
- same destination via the smtp message delivery
+ The maximal number of parallel deliveries to the
+ same destination via the smtp message delivery
transport.
smtp_destination_recipient_limit ($default_destina-
tion_recipient_limit)
- The maximal number of recipients per delivery via
+ The maximal number of recipients per delivery via
the smtp message delivery transport.
smtp_connect_timeout (30s)
- The SMTP client time limit for completing a TCP
+ The SMTP client time limit for completing a TCP
connection, or zero (use the operating system
built-in time limit).
smtp_helo_timeout (300s)
- The SMTP client time limit for sending the HELO or
- EHLO command, and for receiving the initial server
+ The SMTP client time limit for sending the HELO or
+ EHLO command, and for receiving the initial server
response.
smtp_xforward_timeout (300s)
@@ -192,30 +197,30 @@ SMTP(8) SMTP(8)
command, and for receiving the server response.
smtp_mail_timeout (300s)
- The SMTP client time limit for sending the MAIL
- FROM command, and for receiving the server
+ The SMTP client time limit for sending the MAIL
+ FROM command, and for receiving the server
response.
smtp_rcpt_timeout (300s)
- The SMTP client time limit for sending the SMTP
- RCPT TO command, and for receiving the server
+ The SMTP client time limit for sending the SMTP
+ RCPT TO command, and for receiving the server
response.
smtp_data_init_timeout (120s)
- The SMTP client time limit for sending the SMTP
- DATA command, and for receiving the server
+ The SMTP client time limit for sending the SMTP
+ DATA command, and for receiving the server
response.
smtp_data_xfer_timeout (180s)
- The SMTP client time limit for sending the SMTP
+ The SMTP client time limit for sending the SMTP
message content.
smtp_data_done_timeout (600s)
- The SMTP client time limit for sending the SMTP
+ The SMTP client time limit for sending the SMTP
".", and for receiving the server response.
smtp_quit_timeout (300s)
- The SMTP client time limit for sending the QUIT
+ The SMTP client time limit for sending the QUIT
command, and for receiving the server response.
Available in Postfix version 2.1 and later:
@@ -226,23 +231,28 @@ SMTP(8) SMTP(8)
lookups, or zero (no limit).
smtp_mx_session_limit (2)
- The maximal number of SMTP sessions per delivery
- request before giving up or delivering to a fall-
+ The maximal number of SMTP sessions per delivery
+ request before giving up or delivering to a fall-
back relay host, or zero (no limit).
smtp_rset_timeout (20s)
- The SMTP client time limit for sending the RSET
+ The SMTP client time limit for sending the RSET
command, and for receiving the server response.
Available in Postfix version 2.2 and later:
smtp_connection_cache_destinations (empty)
- The SMTP destinations for which SMTP connection
- caching is enabled.
+ Permanently enable SMTP connection caching for the
+ specified destinations.
+
+ smtp_connection_cache_on_demand (yes)
+ Temporarily enable SMTP session caching while a
+ destination has a high volume of mail in the active
+ queue.
smtp_connection_cache_reuse_limit (10)
When SMTP session caching is enabled, the number of
- times that an SMTP session is reused before it is
+ times that an SMTP session is reused before it is
closed.
smtp_connection_cache_time_limit (2s)
@@ -252,46 +262,46 @@ SMTP(8) SMTP(8)
TROUBLE SHOOTING CONTROLS
debug_peer_level (2)
- The increment in verbose logging level when a
- remote client or server matches a pattern in the
+ The increment in verbose logging level when a
+ remote client or server matches a pattern in the
debug_peer_list parameter.
debug_peer_list (empty)
- Optional list of remote client or server hostname
- or network address patterns that cause the verbose
- logging level to increase by the amount specified
+ Optional list of remote client or server hostname
+ or network address patterns that cause the verbose
+ logging level to increase by the amount specified
in $debug_peer_level.
error_notice_recipient (postmaster)
- The recipient of postmaster notifications about
- mail delivery problems that are caused by policy,
+ The recipient of postmaster notifications about
+ mail delivery problems that are caused by policy,
resource, software or protocol errors.
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.
MISCELLANEOUS CONTROLS
best_mx_transport (empty)
- Where the Postfix SMTP client should deliver mail
+ Where the Postfix SMTP client should deliver mail
when it detects a "mail loops back to myself" error
condition.
config_directory (see 'postconf -d' output)
- The default location of the Postfix main.cf and
+ The default location of the Postfix main.cf and
master.cf configuration files.
daemon_timeout (18000s)
- How much time a Postfix daemon process may take to
- handle a request before it is terminated by a
+ How much time a Postfix daemon process may take to
+ handle a request before it is terminated by a
built-in watchdog timer.
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)
@@ -303,25 +313,25 @@ 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 pro-
+ The process ID of a Postfix command or daemon pro-
cess.
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)
@@ -329,22 +339,22 @@ SMTP(8) SMTP(8)
client should bind to when making a connection.
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 pro-
+ The mail system name that is prepended to the pro-
cess name in syslog records, so that "smtpd"
becomes, for example, "postfix/smtpd".
@@ -360,7 +370,7 @@ SMTP(8) SMTP(8)
SASL_README, Postfix SASL 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/man/man1/smtp-source.1 b/postfix/man/man1/smtp-source.1
index a593c06b6..7ecff0351 100644
--- a/postfix/man/man1/smtp-source.1
+++ b/postfix/man/man1/smtp-source.1
@@ -45,6 +45,12 @@ include message headers.
Speak LMTP rather than SMTP.
.IP "\fB-m \fImessage_count\fR"
Send the specified number of messages (default: 1).
+.IP "\fB-N\fR"
+Prepend a non-repeating sequence number to each recipient
+address. This avoids the artificial 100% hit rate in the
+resolve and rewrite client caches and exercises the
+trivial-rewrite daemon, better approximating Postfix
+performance under real-life work-loads.
.IP "\fB-r \fIrecipient_count\fR"
Send the specified number of recipients per transaction (default: 1).
Recipient names are generated by prepending a number to the
diff --git a/postfix/man/man5/postconf.5 b/postfix/man/man5/postconf.5
index f520c1710..360055e19 100644
--- a/postfix/man/man5/postconf.5
+++ b/postfix/man/man5/postconf.5
@@ -2698,10 +2698,10 @@ the operating system).
Time units: s (seconds), m (minutes), h (hours), d (days), w (weeks).
The default time unit is s (seconds).
.SH smtp_connection_cache_destinations (default: empty)
-The SMTP destinations for which SMTP connection caching is
-enabled. With SMTP connection caching, a connection is not closed
-immediately after completion of a mail transaction. Instead, the
-connection is kept open for up to $smtp_connection_cache_time_limit
+Permanently enable SMTP connection caching for the specified
+destinations. With SMTP connection caching, a connection is not
+closed immediately after completion of a mail transaction. Instead,
+the connection is kept open for up to $smtp_connection_cache_time_limit
seconds. This allows connections to be reused for other deliveries,
and can improve mail delivery performance.
.PP
@@ -2721,6 +2721,16 @@ a "type:table" with domains and/or relay hosts on the left-hand
side. The right-hand side result from "type:table" lookups is
ignored.
.PP
+.SH smtp_connection_cache_on_demand (default: yes)
+Temporarily enable SMTP session caching while a destination
+has a high volume of mail in the active queue. With SMTP connection
+caching, a connection is not closed immediately after completion
+of a mail transaction. Instead, the connection is kept open for
+up to $smtp_connection_cache_time_limit seconds. This allows
+connections to be reused for other deliveries, and can improve mail
+delivery performance.
+.PP
+This feature is available in Postfix 2.2 and later.
.SH smtp_connection_cache_reuse_limit (default: 10)
When SMTP session caching is enabled, the number of times that
an SMTP session is reused before it is closed.
diff --git a/postfix/man/man8/smtp.8 b/postfix/man/man8/smtp.8
index cc98f8252..f6f530e28 100644
--- a/postfix/man/man8/smtp.8
+++ b/postfix/man/man8/smtp.8
@@ -35,7 +35,11 @@ deliver the mail to an alternate host.
After a successful mail transaction, a session may be saved
to the \fBscache(8)\fR session cache server, so that it
may be used by any SMTP client for a subsequent transaction.
-Session caching is disabled by default.
+
+By default, session caching is enabled temporarily for
+destinations that have a high volume of mail in the active
+queue. Session caching can be enabled permanently for
+specific destinations.
.SH "SECURITY"
.na
.nf
@@ -210,8 +214,11 @@ for receiving the server response.
.PP
Available in Postfix version 2.2 and later:
.IP "\fBsmtp_connection_cache_destinations (empty)\fR"
-The SMTP destinations for which SMTP connection caching is
-enabled.
+Permanently enable SMTP connection caching for the specified
+destinations.
+.IP "\fBsmtp_connection_cache_on_demand (yes)\fR"
+Temporarily enable SMTP session caching while a destination
+has a high volume of mail in the active queue.
.IP "\fBsmtp_connection_cache_reuse_limit (10)\fR"
When SMTP session caching is enabled, the number of times that
an SMTP session is reused before it is closed.
diff --git a/postfix/proto/postconf.proto b/postfix/proto/postconf.proto
index 6cee85a30..dcae6958c 100644
--- a/postfix/proto/postconf.proto
+++ b/postfix/proto/postconf.proto
@@ -3187,10 +3187,10 @@ an SMTP session is reused before it is closed.
%PARAM smtp_connection_cache_destinations
- The SMTP destinations for which SMTP connection caching is
-enabled. With SMTP connection caching, a connection is not closed
-immediately after completion of a mail transaction. Instead, the
-connection is kept open for up to $smtp_connection_cache_time_limit
+
Permanently enable SMTP connection caching for the specified
+destinations. With SMTP connection caching, a connection is not
+closed immediately after completion of a mail transaction. Instead,
+the connection is kept open for up to $smtp_connection_cache_time_limit
seconds. This allows connections to be reused for other deliveries,
and can improve mail delivery performance.
@@ -3217,6 +3217,18 @@ ignored.
+%PARAM smtp_connection_cache_on_demand yes
+
+ Temporarily enable SMTP session caching while a destination
+has a high volume of mail in the active queue. With SMTP connection
+caching, a connection is not closed immediately after completion
+of a mail transaction. Instead, the connection is kept open for
+up to $smtp_connection_cache_time_limit seconds. This allows
+connections to be reused for other deliveries, and can improve mail
+delivery performance.
+
+ This feature is available in Postfix 2.2 and later.
+
%PARAM smtp_connect_timeout 30s
diff --git a/postfix/src/global/deliver_request.h b/postfix/src/global/deliver_request.h
index 6017878be..ef541ed96 100644
--- a/postfix/src/global/deliver_request.h
+++ b/postfix/src/global/deliver_request.h
@@ -62,6 +62,7 @@ typedef struct DELIVER_REQUEST {
#define DEL_REQ_FLAG_VERIFY (1<<8) /* verify recipient, don't deliver */
#define DEL_REQ_FLAG_EXPAND (1<<9) /* verify expansion, don't deliver */
#define DEL_REQ_FLAG_RECORD (1<<10) /* record and deliver */
+#define DEL_REQ_FLAG_SCACHE (1<<11) /* opportunistic caching */
#define DEL_REQ_TRACE_FLAGS_MASK \
(DEL_REQ_FLAG_VERIFY | DEL_REQ_FLAG_EXPAND | DEL_REQ_FLAG_RECORD)
diff --git a/postfix/src/global/mail_params.h b/postfix/src/global/mail_params.h
index 9bdd34cef..fb4a00e78 100644
--- a/postfix/src/global/mail_params.h
+++ b/postfix/src/global/mail_params.h
@@ -781,6 +781,10 @@ extern int var_smtp_reuse_limit;
#define DEF_SMTP_CACHE_DEST ""
extern char *var_smtp_cache_dest;
+#define VAR_SMTP_CACHE_DEMAND "smtp_connection_cache_on_demand"
+#define DEF_SMTP_CACHE_DEMAND 1
+extern bool var_smtp_cache_demand;
+
#define VAR_SMTP_CONN_TMOUT "smtp_connect_timeout"
#define DEF_SMTP_CONN_TMOUT "30s"
extern int var_smtp_conn_tmout;
diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h
index 477479d4d..9c3c89920 100644
--- a/postfix/src/global/mail_version.h
+++ b/postfix/src/global/mail_version.h
@@ -20,7 +20,7 @@
* Patches change the patchlevel and the release date. Snapshots change the
* release date only.
*/
-#define MAIL_RELEASE_DATE "20040723"
+#define MAIL_RELEASE_DATE "20040729"
#define MAIL_VERSION_NUMBER "2.2"
#define VAR_MAIL_VERSION "mail_version"
diff --git a/postfix/src/oqmgr/Makefile.in b/postfix/src/oqmgr/Makefile.in
index 63b9590c4..37a7e44bc 100644
--- a/postfix/src/oqmgr/Makefile.in
+++ b/postfix/src/oqmgr/Makefile.in
@@ -155,6 +155,9 @@ qmgr_entry.o: ../../include/events.h
qmgr_entry.o: ../../include/vstream.h
qmgr_entry.o: ../../include/vbuf.h
qmgr_entry.o: ../../include/mail_params.h
+qmgr_entry.o: ../../include/deliver_request.h
+qmgr_entry.o: ../../include/vstring.h
+qmgr_entry.o: ../../include/recipient_list.h
qmgr_entry.o: qmgr.h
qmgr_entry.o: ../../include/scan_dir.h
qmgr_message.o: qmgr_message.c
diff --git a/postfix/src/oqmgr/qmgr.h b/postfix/src/oqmgr/qmgr.h
index 3a5e3ca84..f3c59d95f 100644
--- a/postfix/src/oqmgr/qmgr.h
+++ b/postfix/src/oqmgr/qmgr.h
@@ -140,6 +140,7 @@ struct QMGR_ENTRY_LIST {
};
struct QMGR_QUEUE {
+ int dflags; /* delivery request options */
char *name; /* domain name or address */
char *nexthop; /* domain name */
int todo_refcount; /* queue entries (todo list) */
diff --git a/postfix/src/oqmgr/qmgr_deliver.c b/postfix/src/oqmgr/qmgr_deliver.c
index 60e2378d7..ea6650666 100644
--- a/postfix/src/oqmgr/qmgr_deliver.c
+++ b/postfix/src/oqmgr/qmgr_deliver.c
@@ -143,6 +143,7 @@ static int qmgr_deliver_send_request(QMGR_ENTRY *entry, VSTREAM *stream)
}
flags = message->tflags
+ | entry->queue->dflags
| (message->inspect_xport ? DEL_REQ_FLAG_BOUNCE : DEL_REQ_FLAG_DEFLT);
attr_print(stream, ATTR_FLAG_MORE,
ATTR_TYPE_NUM, MAIL_ATTR_FLAGS, flags,
diff --git a/postfix/src/oqmgr/qmgr_entry.c b/postfix/src/oqmgr/qmgr_entry.c
index 3d3f9f461..01240fb4b 100644
--- a/postfix/src/oqmgr/qmgr_entry.c
+++ b/postfix/src/oqmgr/qmgr_entry.c
@@ -84,6 +84,7 @@
/* Global library. */
#include
+#include /* opportunistic session caching */
/* Application-specific. */
@@ -187,6 +188,7 @@ void qmgr_entry_done(QMGR_ENTRY *entry, int which)
QMGR_ENTRY *qmgr_entry_create(QMGR_QUEUE *queue, QMGR_MESSAGE *message)
{
+ char *myname = "qmgr_entry_create";
QMGR_ENTRY *entry;
/*
@@ -207,6 +209,22 @@ QMGR_ENTRY *qmgr_entry_create(QMGR_QUEUE *queue, QMGR_MESSAGE *message)
QMGR_LIST_APPEND(queue->todo, entry);
queue->todo_refcount++;
+ /*
+ * With opportunistic session caching, the delivery agent must not only
+ * 1) save a session upon completion, but also 2) reuse a cached session
+ * upon the next delivery request. In order to not miss out on 2), we
+ * have to make caching sticky or else we get silly behavior when the
+ * in-memory queue drains. New connections must not be made while cached
+ * connections aren't being reused.
+ */
+ if ((queue->dflags & DEL_REQ_FLAG_SCACHE) == 0
+ && queue->window < queue->todo_refcount + queue->busy_refcount) {
+ if (msg_verbose)
+ msg_info("%s: passing on-demand session caching threshold for %s",
+ myname, queue->name);
+ queue->dflags |= DEL_REQ_FLAG_SCACHE;
+ }
+
/*
* Warn if a destination is falling behind while the active queue
* contains a non-trivial amount of single-recipient email. When a
diff --git a/postfix/src/oqmgr/qmgr_queue.c b/postfix/src/oqmgr/qmgr_queue.c
index 3c88b7eda..810d9edc5 100644
--- a/postfix/src/oqmgr/qmgr_queue.c
+++ b/postfix/src/oqmgr/qmgr_queue.c
@@ -183,6 +183,7 @@ void qmgr_queue_throttle(QMGR_QUEUE *queue, const char *reason)
queue->reason = mystrdup(reason);
event_request_timer(qmgr_queue_unthrottle_wrapper,
(char *) queue, var_min_backoff_time);
+ queue->dflags = 0;
}
}
@@ -254,6 +255,7 @@ QMGR_QUEUE *qmgr_queue_create(QMGR_TRANSPORT *transport, const char *name,
queue = (QMGR_QUEUE *) mymalloc(sizeof(QMGR_QUEUE));
qmgr_queue_count++;
+ queue->dflags = 0;
queue->name = mystrdup(name);
queue->nexthop = mystrdup(nexthop);
queue->todo_refcount = 0;
diff --git a/postfix/src/qmgr/Makefile.in b/postfix/src/qmgr/Makefile.in
index 3239af285..368bd255c 100644
--- a/postfix/src/qmgr/Makefile.in
+++ b/postfix/src/qmgr/Makefile.in
@@ -157,6 +157,9 @@ qmgr_entry.o: ../../include/events.h
qmgr_entry.o: ../../include/vstream.h
qmgr_entry.o: ../../include/vbuf.h
qmgr_entry.o: ../../include/mail_params.h
+qmgr_entry.o: ../../include/deliver_request.h
+qmgr_entry.o: ../../include/vstring.h
+qmgr_entry.o: ../../include/recipient_list.h
qmgr_entry.o: qmgr.h
qmgr_entry.o: ../../include/scan_dir.h
qmgr_job.o: qmgr_job.c
diff --git a/postfix/src/qmgr/qmgr.h b/postfix/src/qmgr/qmgr.h
index 141873c20..6c285358e 100644
--- a/postfix/src/qmgr/qmgr.h
+++ b/postfix/src/qmgr/qmgr.h
@@ -176,6 +176,7 @@ struct QMGR_ENTRY_LIST {
};
struct QMGR_QUEUE {
+ int dflags; /* delivery request options */
char *name; /* domain name or address */
char *nexthop; /* domain name */
int todo_refcount; /* queue entries (todo list) */
diff --git a/postfix/src/qmgr/qmgr_deliver.c b/postfix/src/qmgr/qmgr_deliver.c
index 34fdb465d..178f93d5e 100644
--- a/postfix/src/qmgr/qmgr_deliver.c
+++ b/postfix/src/qmgr/qmgr_deliver.c
@@ -148,6 +148,7 @@ static int qmgr_deliver_send_request(QMGR_ENTRY *entry, VSTREAM *stream)
}
flags = message->tflags
+ | entry->queue->dflags
| (message->inspect_xport ? DEL_REQ_FLAG_BOUNCE : DEL_REQ_FLAG_DEFLT);
attr_print(stream, ATTR_FLAG_MORE,
ATTR_TYPE_NUM, MAIL_ATTR_FLAGS, flags,
diff --git a/postfix/src/qmgr/qmgr_entry.c b/postfix/src/qmgr/qmgr_entry.c
index c26d29325..bfb6d2e59 100644
--- a/postfix/src/qmgr/qmgr_entry.c
+++ b/postfix/src/qmgr/qmgr_entry.c
@@ -92,6 +92,7 @@
/* Global library. */
#include
+#include /* opportunistic session caching */
/* Application-specific. */
@@ -244,6 +245,7 @@ void qmgr_entry_done(QMGR_ENTRY *entry, int which)
QMGR_ENTRY *qmgr_entry_create(QMGR_PEER *peer, QMGR_MESSAGE *message)
{
+ char *myname = "qmgr_entry_create";
QMGR_ENTRY *entry;
QMGR_QUEUE *queue = peer->queue;
@@ -268,6 +270,22 @@ QMGR_ENTRY *qmgr_entry_create(QMGR_PEER *peer, QMGR_MESSAGE *message)
QMGR_LIST_APPEND(queue->todo, entry, queue_peers);
queue->todo_refcount++;
+ /*
+ * With opportunistic session caching, the delivery agent must not only
+ * 1) save a session upon completion, but also 2) reuse a cached session
+ * upon the next delivery request. In order to not miss out on 2), we
+ * have to make caching sticky or else we get silly behavior when the
+ * in-memory queue drains. New connections must not be made while cached
+ * connections aren't being reused.
+ */
+ if ((queue->dflags & DEL_REQ_FLAG_SCACHE) == 0
+ && queue->window < queue->todo_refcount + queue->busy_refcount) {
+ if (msg_verbose)
+ msg_info("%s: passing on-demand session caching threshold for %s",
+ myname, queue->name);
+ queue->dflags |= DEL_REQ_FLAG_SCACHE;
+ }
+
/*
* Warn if a destination is falling behind while the active queue
* contains a non-trivial amount of single-recipient email. When a
diff --git a/postfix/src/qmgr/qmgr_queue.c b/postfix/src/qmgr/qmgr_queue.c
index b86034a57..262ce5e70 100644
--- a/postfix/src/qmgr/qmgr_queue.c
+++ b/postfix/src/qmgr/qmgr_queue.c
@@ -181,6 +181,7 @@ void qmgr_queue_throttle(QMGR_QUEUE *queue, const char *reason)
queue->reason = mystrdup(reason);
event_request_timer(qmgr_queue_unthrottle_wrapper,
(char *) queue, var_min_backoff_time);
+ queue->dflags = 0;
}
}
@@ -231,6 +232,7 @@ QMGR_QUEUE *qmgr_queue_create(QMGR_TRANSPORT *transport, const char *name,
queue = (QMGR_QUEUE *) mymalloc(sizeof(QMGR_QUEUE));
qmgr_queue_count++;
+ queue->dflags = 0;
queue->name = mystrdup(name);
queue->nexthop = mystrdup(nexthop);
queue->todo_refcount = 0;
diff --git a/postfix/src/smtp/smtp.c b/postfix/src/smtp/smtp.c
index 095d00c18..1431de19d 100644
--- a/postfix/src/smtp/smtp.c
+++ b/postfix/src/smtp/smtp.c
@@ -29,7 +29,11 @@
/* After a successful mail transaction, a session may be saved
/* to the \fBscache(8)\fR session cache server, so that it
/* may be used by any SMTP client for a subsequent transaction.
-/* Session caching is disabled by default.
+/*
+/* By default, session caching is enabled temporarily for
+/* destinations that have a high volume of mail in the active
+/* queue. Session caching can be enabled permanently for
+/* specific destinations.
/* SECURITY
/* .ad
/* .fi
@@ -184,8 +188,11 @@
/* .PP
/* Available in Postfix version 2.2 and later:
/* .IP "\fBsmtp_connection_cache_destinations (empty)\fR"
-/* The SMTP destinations for which SMTP connection caching is
-/* enabled.
+/* Permanently enable SMTP connection caching for the specified
+/* destinations.
+/* .IP "\fBsmtp_connection_cache_on_demand (yes)\fR"
+/* Temporarily enable SMTP session caching while a destination
+/* has a high volume of mail in the active queue.
/* .IP "\fBsmtp_connection_cache_reuse_limit (10)\fR"
/* When SMTP session caching is enabled, the number of times that
/* an SMTP session is reused before it is closed.
@@ -374,6 +381,7 @@ int var_smtp_cache_conn;
int var_smtp_reuse_limit;
char *var_smtp_cache_dest;
char *var_scache_service;
+bool var_smtp_cache_demand;
/*
* Global variables. smtp_errno is set by the address lookup routines and by
@@ -489,7 +497,7 @@ static void post_init(char *unused_name, char **unused_argv)
/*
* Session cache instance.
*/
- if (*var_smtp_cache_dest)
+ if (*var_smtp_cache_dest || var_smtp_cache_demand)
#if 0
smtp_scache = scache_multi_create();
#else
@@ -601,6 +609,7 @@ int main(int argc, char **argv)
VAR_SMTP_QUOTE_821_ENV, DEF_SMTP_QUOTE_821_ENV, &var_smtp_quote_821_env,
VAR_SMTP_DEFER_MXADDR, DEF_SMTP_DEFER_MXADDR, &var_smtp_defer_mxaddr,
VAR_SMTP_SEND_XFORWARD, DEF_SMTP_SEND_XFORWARD, &var_smtp_send_xforward,
+ VAR_SMTP_CACHE_DEMAND, DEF_SMTP_CACHE_DEMAND, &var_smtp_cache_demand,
0,
};
diff --git a/postfix/src/smtp/smtp_connect.c b/postfix/src/smtp/smtp_connect.c
index 600b6fa5d..8ae3dcfa4 100644
--- a/postfix/src/smtp/smtp_connect.c
+++ b/postfix/src/smtp/smtp_connect.c
@@ -521,10 +521,14 @@ int smtp_connect(SMTP_STATE *state)
* :port, because : is already used for maptype:mapname. Because of
* this limitation we use the bare domain without the optional [] or
* non-default TCP port.
+ *
+ * Opportunistic (a.k.a. on-demand) session caching on request by the
+ * queue manager. This is turned temporarily when a destination has a
+ * high volume of mail in the active queue.
*/
if (cpp == sites->argv
- && smtp_cache_dest
- && string_list_match(smtp_cache_dest, domain)) {
+ && ((request->flags & DEL_REQ_FLAG_SCACHE) != 0
+ || (smtp_cache_dest && string_list_match(smtp_cache_dest, domain)))) {
sess_flags |= SMTP_SESS_FLAG_CACHE;
SET_NEXTHOP_STATE(state, lookup_mx, domain, port);
}
diff --git a/postfix/src/smtpstone/smtp-source.c b/postfix/src/smtpstone/smtp-source.c
index 106f30bb3..4a6d7df40 100644
--- a/postfix/src/smtpstone/smtp-source.c
+++ b/postfix/src/smtpstone/smtp-source.c
@@ -39,6 +39,12 @@
/* Speak LMTP rather than SMTP.
/* .IP "\fB-m \fImessage_count\fR"
/* Send the specified number of messages (default: 1).
+/* .IP "\fB-N\fR"
+/* Prepend a non-repeating sequence number to each recipient
+/* address. This avoids the artificial 100% hit rate in the
+/* resolve and rewrite client caches and exercises the
+/* trivial-rewrite daemon, better approximating Postfix
+/* performance under real-life work-loads.
/* .IP "\fB-r \fIrecipient_count\fR"
/* Send the specified number of recipients per transaction (default: 1).
/* Recipient names are generated by prepending a number to the
@@ -171,6 +177,7 @@ static int random_delay = 0;
static int fixed_delay = 0;
static int talk_lmtp = 0;
static char *subject = 0;
+static int number_rcpts = 0;
static void enqueue_connect(SESSION *);
static void start_connect(SESSION *);
@@ -573,9 +580,10 @@ static void send_rcpt(int unused_event, char *context)
if ((except = vstream_setjmp(session->stream)) != 0)
msg_fatal("%s while sending recipient", exception_text(except));
- if (session->rcpt_count > 1)
+ if (session->rcpt_count > 1 || number_rcpts > 0)
command(session->stream, "RCPT TO:<%d%s>",
- session->rcpt_count, recipient);
+ number_rcpts ? number_rcpts++ : session->rcpt_count,
+ recipient);
else
command(session->stream, "RCPT TO:<%s>", recipient);
session->rcpt_count--;
@@ -767,7 +775,7 @@ static void quit_done(int unused_event, char *context)
static void usage(char *myname)
{
- msg_fatal("usage: %s -s sess -l msglen -m msgs -c -C count -d -f from -o -t to -r rcptcount -R delay -v -w delay host[:port]", myname);
+ msg_fatal("usage: %s -cdLNov -s sess -l msglen -m msgs -C count -f from -t to -r rcptcount -R delay -w delay host[:port]", myname);
}
/* main - parse JCL and start the machine */
@@ -789,7 +797,7 @@ int main(int argc, char **argv)
/*
* Parse JCL.
*/
- while ((ch = GETOPT(argc, argv, "cC:df:l:Lm:or:R:s:S:t:vw:")) > 0) {
+ while ((ch = GETOPT(argc, argv, "cC:df:l:Lm:Nor:R:s:S:t:vw:")) > 0) {
switch (ch) {
case 'c':
count++;
@@ -822,6 +830,9 @@ int main(int argc, char **argv)
if ((message_count = atoi(optarg)) <= 0)
msg_fatal("bad message count: %s", optarg);
break;
+ case 'N':
+ number_rcpts = 1;
+ break;
case 'o':
send_helo_first = 0;
send_headers = 0;