2
0
mirror of https://github.com/vdukhovni/postfix synced 2025-08-31 06:05:37 +00:00

postfix-2.2-20040729

This commit is contained in:
Wietse Venema
2004-07-29 00:00:00 -05:00
committed by Viktor Dukhovni
parent e65de76573
commit 539ba25d8b
25 changed files with 289 additions and 114 deletions

View File

@@ -9583,12 +9583,12 @@ Apologies for any names omitted.
recvmsg(). Workaround is to insert an intervening read recvmsg(). Workaround is to insert an intervening read
(write) operation. Presumably, LINUX 2.4 is confusing the (write) operation. Presumably, LINUX 2.4 is confusing the
data and file descriptor. Lucky Ralf Hildebrandt. Files: 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 20040723
Bug? Safety? spawn(8) did not reject a user with the -1 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. util/spawn_command.c, src/util/spawn.c.
User interface: parameter smtp_connection_cache_domains 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(). Bugfix: "421 Timeout exceeded" wasn't guarded by setjmp().
Victor Duchovni, Morgan Stanley. File: smtpd/smtpd.c. 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: Open problems:
Low: update events.c so that 1-second timer requests do Low: update events.c so that 1-second timer requests do

View File

@@ -7,14 +7,30 @@ snapshot release). Patches are issued for the official release
and change the patchlevel and the release date. Patches are never and change the patchlevel and the release date. Patches are never
issued for snapshot releases. 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 Incompatible changes with snapshot Postfix-2.2-20040723
======================================================= =======================================================
Session caching is enabled with smtp_session_cache_destinations, Permanent SMTP session caching is now enabled with the
and requires "bare" domain names without "[]" or TCP port. This smtp_session_cache_destinations parameter. This requires "bare"
eliminates a syntax conflict between host:port and maptype:mapname, domain names without "[]" or TCP port. The change eliminates a
and simplifies the user interface, at the cost of a minor loss of syntax conflict between host:port and maptype:mapname, and simplifies
control over what sessions are cached. 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 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 Major changes with snapshot Postfix-2.2-20040720
================================================ ================================================
Selective SMTP session caching. Instead of disconnecting immediately Selective permanent SMTP session caching. Instead of disconnecting
after a mail transaction, the SMTP client can save the open session immediately after a mail transaction, the SMTP client can save the
to a session cache daemon, so that any SMTP client process can use open session to a session cache daemon, so that any SMTP client
that session for another mail transaction. process can use that session for another mail transaction.
This feature introduces the scache (session cache) server, which This feature introduces the scache (session cache) server, which
is added to your master.cf file when you upgrade Postfix. is added to your master.cf file when you upgrade Postfix.

View File

@@ -5169,10 +5169,10 @@ The default time unit is s (seconds).
<DT><b><a name="smtp_connection_cache_destinations">smtp_connection_cache_destinations</a> <DT><b><a name="smtp_connection_cache_destinations">smtp_connection_cache_destinations</a>
(default: empty)</b></DT><DD> (default: empty)</b></DT><DD>
<p> The SMTP destinations for which SMTP connection caching is <p> Permanently enable SMTP connection caching for the specified
enabled. With SMTP connection caching, a connection is not closed destinations. With SMTP connection caching, a connection is not
immediately after completion of a mail transaction. Instead, the closed immediately after completion of a mail transaction. Instead,
connection is kept open for up to $<a href="postconf.5.html#smtp_connection_cache_time_limit">smtp_connection_cache_time_limit</a> the connection is kept open for up to $<a href="postconf.5.html#smtp_connection_cache_time_limit">smtp_connection_cache_time_limit</a>
seconds. This allows connections to be reused for other deliveries, seconds. This allows connections to be reused for other deliveries,
and can improve mail delivery performance. </p> and can improve mail delivery performance. </p>
@@ -5200,6 +5200,22 @@ ignored.
<p></p> <p></p>
</DD>
<DT><b><a name="smtp_connection_cache_on_demand">smtp_connection_cache_on_demand</a>
(default: yes)</b></DT><DD>
<p> Temporarily enable SMTP session caching while a destination
has a high volume of mail in the <a href="QSHAPE_README.html#active_queue">active queue</a>. 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 $<a href="postconf.5.html#smtp_connection_cache_time_limit">smtp_connection_cache_time_limit</a> seconds. This allows
connections to be reused for other deliveries, and can improve mail
delivery performance. </p>
<p> This feature is available in Postfix 2.2 and later. </p>
</DD> </DD>
<DT><b><a name="smtp_connection_cache_reuse_limit">smtp_connection_cache_reuse_limit</a> <DT><b><a name="smtp_connection_cache_reuse_limit">smtp_connection_cache_reuse_limit</a>

View File

@@ -52,6 +52,13 @@ SMTP-SOURCE(1) SMTP-SOURCE(1)
<b>-m</b> <i>message</i><b>_</b><i>count</i> <b>-m</b> <i>message</i><b>_</b><i>count</i>
Send the specified number of messages (default: 1). Send the specified number of messages (default: 1).
<b>-N</b> 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.
<b>-r</b> <i>recipient</i><b>_</b><i>count</i> <b>-r</b> <i>recipient</i><b>_</b><i>count</i>
Send the specified number of recipients per trans- Send the specified number of recipients per trans-
action (default: 1). Recipient names are generated action (default: 1). Recipient names are generated

View File

@@ -37,7 +37,12 @@ SMTP(8) SMTP(8)
After a successful mail transaction, a session may be After a successful mail transaction, a session may be
saved to the <a href="scache.8.html"><b>scache(8)</a></b> session cache server, so that it saved to the <a href="scache.8.html"><b>scache(8)</a></b> session cache server, so that it
may be used by any SMTP client for a subsequent transac- 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.
<b>SECURITY</b> <b>SECURITY</b>
The SMTP client is moderately security-sensitive. It talks The SMTP client is moderately security-sensitive. It talks
@@ -237,8 +242,13 @@ SMTP(8) SMTP(8)
Available in Postfix version 2.2 and later: Available in Postfix version 2.2 and later:
<b><a href="postconf.5.html#smtp_connection_cache_destinations">smtp_connection_cache_destinations</a> (empty)</b> <b><a href="postconf.5.html#smtp_connection_cache_destinations">smtp_connection_cache_destinations</a> (empty)</b>
The SMTP destinations for which SMTP connection Permanently enable SMTP connection caching for the
caching is enabled. specified destinations.
<b>smtp_connection_cache_on_demand (yes)</b>
Temporarily enable SMTP session caching while a
destination has a high volume of mail in the active
queue.
<b><a href="postconf.5.html#smtp_connection_cache_reuse_limit">smtp_connection_cache_reuse_limit</a> (10)</b> <b><a href="postconf.5.html#smtp_connection_cache_reuse_limit">smtp_connection_cache_reuse_limit</a> (10)</b>
When SMTP session caching is enabled, the number of When SMTP session caching is enabled, the number of

View File

@@ -45,6 +45,12 @@ include message headers.
Speak LMTP rather than SMTP. Speak LMTP rather than SMTP.
.IP "\fB-m \fImessage_count\fR" .IP "\fB-m \fImessage_count\fR"
Send the specified number of messages (default: 1). 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" .IP "\fB-r \fIrecipient_count\fR"
Send the specified number of recipients per transaction (default: 1). Send the specified number of recipients per transaction (default: 1).
Recipient names are generated by prepending a number to the Recipient names are generated by prepending a number to the

View File

@@ -2698,10 +2698,10 @@ the operating system).
Time units: s (seconds), m (minutes), h (hours), d (days), w (weeks). Time units: s (seconds), m (minutes), h (hours), d (days), w (weeks).
The default time unit is s (seconds). The default time unit is s (seconds).
.SH smtp_connection_cache_destinations (default: empty) .SH smtp_connection_cache_destinations (default: empty)
The SMTP destinations for which SMTP connection caching is Permanently enable SMTP connection caching for the specified
enabled. With SMTP connection caching, a connection is not closed destinations. With SMTP connection caching, a connection is not
immediately after completion of a mail transaction. Instead, the closed immediately after completion of a mail transaction. Instead,
connection is kept open for up to $smtp_connection_cache_time_limit the connection is kept open for up to $smtp_connection_cache_time_limit
seconds. This allows connections to be reused for other deliveries, seconds. This allows connections to be reused for other deliveries,
and can improve mail delivery performance. and can improve mail delivery performance.
.PP .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 side. The right-hand side result from "type:table" lookups is
ignored. ignored.
.PP .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) .SH smtp_connection_cache_reuse_limit (default: 10)
When SMTP session caching is enabled, the number of times that When SMTP session caching is enabled, the number of times that
an SMTP session is reused before it is closed. an SMTP session is reused before it is closed.

View File

@@ -35,7 +35,11 @@ deliver the mail to an alternate host.
After a successful mail transaction, a session may be saved After a successful mail transaction, a session may be saved
to the \fBscache(8)\fR session cache server, so that it to the \fBscache(8)\fR session cache server, so that it
may be used by any SMTP client for a subsequent transaction. 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" .SH "SECURITY"
.na .na
.nf .nf
@@ -210,8 +214,11 @@ for receiving the server response.
.PP .PP
Available in Postfix version 2.2 and later: Available in Postfix version 2.2 and later:
.IP "\fBsmtp_connection_cache_destinations (empty)\fR" .IP "\fBsmtp_connection_cache_destinations (empty)\fR"
The SMTP destinations for which SMTP connection caching is Permanently enable SMTP connection caching for the specified
enabled. 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" .IP "\fBsmtp_connection_cache_reuse_limit (10)\fR"
When SMTP session caching is enabled, the number of times that When SMTP session caching is enabled, the number of times that
an SMTP session is reused before it is closed. an SMTP session is reused before it is closed.

View File

@@ -3187,10 +3187,10 @@ an SMTP session is reused before it is closed.
%PARAM smtp_connection_cache_destinations %PARAM smtp_connection_cache_destinations
<p> The SMTP destinations for which SMTP connection caching is <p> Permanently enable SMTP connection caching for the specified
enabled. With SMTP connection caching, a connection is not closed destinations. With SMTP connection caching, a connection is not
immediately after completion of a mail transaction. Instead, the closed immediately after completion of a mail transaction. Instead,
connection is kept open for up to $smtp_connection_cache_time_limit the connection is kept open for up to $smtp_connection_cache_time_limit
seconds. This allows connections to be reused for other deliveries, seconds. This allows connections to be reused for other deliveries,
and can improve mail delivery performance. </p> and can improve mail delivery performance. </p>
@@ -3217,6 +3217,18 @@ ignored.
<p></p> <p></p>
%PARAM smtp_connection_cache_on_demand yes
<p> 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. </p>
<p> This feature is available in Postfix 2.2 and later. </p>
%PARAM smtp_connect_timeout 30s %PARAM smtp_connect_timeout 30s
<p> <p>

View File

@@ -62,6 +62,7 @@ typedef struct DELIVER_REQUEST {
#define DEL_REQ_FLAG_VERIFY (1<<8) /* verify recipient, don't deliver */ #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_EXPAND (1<<9) /* verify expansion, don't deliver */
#define DEL_REQ_FLAG_RECORD (1<<10) /* record and 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 \ #define DEL_REQ_TRACE_FLAGS_MASK \
(DEL_REQ_FLAG_VERIFY | DEL_REQ_FLAG_EXPAND | DEL_REQ_FLAG_RECORD) (DEL_REQ_FLAG_VERIFY | DEL_REQ_FLAG_EXPAND | DEL_REQ_FLAG_RECORD)

View File

@@ -781,6 +781,10 @@ extern int var_smtp_reuse_limit;
#define DEF_SMTP_CACHE_DEST "" #define DEF_SMTP_CACHE_DEST ""
extern char *var_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 VAR_SMTP_CONN_TMOUT "smtp_connect_timeout"
#define DEF_SMTP_CONN_TMOUT "30s" #define DEF_SMTP_CONN_TMOUT "30s"
extern int var_smtp_conn_tmout; extern int var_smtp_conn_tmout;

View File

@@ -20,7 +20,7 @@
* Patches change the patchlevel and the release date. Snapshots change the * Patches change the patchlevel and the release date. Snapshots change the
* release date only. * release date only.
*/ */
#define MAIL_RELEASE_DATE "20040723" #define MAIL_RELEASE_DATE "20040729"
#define MAIL_VERSION_NUMBER "2.2" #define MAIL_VERSION_NUMBER "2.2"
#define VAR_MAIL_VERSION "mail_version" #define VAR_MAIL_VERSION "mail_version"

View File

@@ -155,6 +155,9 @@ qmgr_entry.o: ../../include/events.h
qmgr_entry.o: ../../include/vstream.h qmgr_entry.o: ../../include/vstream.h
qmgr_entry.o: ../../include/vbuf.h qmgr_entry.o: ../../include/vbuf.h
qmgr_entry.o: ../../include/mail_params.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: qmgr.h
qmgr_entry.o: ../../include/scan_dir.h qmgr_entry.o: ../../include/scan_dir.h
qmgr_message.o: qmgr_message.c qmgr_message.o: qmgr_message.c

View File

@@ -140,6 +140,7 @@ struct QMGR_ENTRY_LIST {
}; };
struct QMGR_QUEUE { struct QMGR_QUEUE {
int dflags; /* delivery request options */
char *name; /* domain name or address */ char *name; /* domain name or address */
char *nexthop; /* domain name */ char *nexthop; /* domain name */
int todo_refcount; /* queue entries (todo list) */ int todo_refcount; /* queue entries (todo list) */

View File

@@ -143,6 +143,7 @@ static int qmgr_deliver_send_request(QMGR_ENTRY *entry, VSTREAM *stream)
} }
flags = message->tflags flags = message->tflags
| entry->queue->dflags
| (message->inspect_xport ? DEL_REQ_FLAG_BOUNCE : DEL_REQ_FLAG_DEFLT); | (message->inspect_xport ? DEL_REQ_FLAG_BOUNCE : DEL_REQ_FLAG_DEFLT);
attr_print(stream, ATTR_FLAG_MORE, attr_print(stream, ATTR_FLAG_MORE,
ATTR_TYPE_NUM, MAIL_ATTR_FLAGS, flags, ATTR_TYPE_NUM, MAIL_ATTR_FLAGS, flags,

View File

@@ -84,6 +84,7 @@
/* Global library. */ /* Global library. */
#include <mail_params.h> #include <mail_params.h>
#include <deliver_request.h> /* opportunistic session caching */
/* Application-specific. */ /* 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) QMGR_ENTRY *qmgr_entry_create(QMGR_QUEUE *queue, QMGR_MESSAGE *message)
{ {
char *myname = "qmgr_entry_create";
QMGR_ENTRY *entry; QMGR_ENTRY *entry;
/* /*
@@ -207,6 +209,22 @@ QMGR_ENTRY *qmgr_entry_create(QMGR_QUEUE *queue, QMGR_MESSAGE *message)
QMGR_LIST_APPEND(queue->todo, entry); QMGR_LIST_APPEND(queue->todo, entry);
queue->todo_refcount++; 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 * Warn if a destination is falling behind while the active queue
* contains a non-trivial amount of single-recipient email. When a * contains a non-trivial amount of single-recipient email. When a

View File

@@ -183,6 +183,7 @@ void qmgr_queue_throttle(QMGR_QUEUE *queue, const char *reason)
queue->reason = mystrdup(reason); queue->reason = mystrdup(reason);
event_request_timer(qmgr_queue_unthrottle_wrapper, event_request_timer(qmgr_queue_unthrottle_wrapper,
(char *) queue, var_min_backoff_time); (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)); queue = (QMGR_QUEUE *) mymalloc(sizeof(QMGR_QUEUE));
qmgr_queue_count++; qmgr_queue_count++;
queue->dflags = 0;
queue->name = mystrdup(name); queue->name = mystrdup(name);
queue->nexthop = mystrdup(nexthop); queue->nexthop = mystrdup(nexthop);
queue->todo_refcount = 0; queue->todo_refcount = 0;

View File

@@ -157,6 +157,9 @@ qmgr_entry.o: ../../include/events.h
qmgr_entry.o: ../../include/vstream.h qmgr_entry.o: ../../include/vstream.h
qmgr_entry.o: ../../include/vbuf.h qmgr_entry.o: ../../include/vbuf.h
qmgr_entry.o: ../../include/mail_params.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: qmgr.h
qmgr_entry.o: ../../include/scan_dir.h qmgr_entry.o: ../../include/scan_dir.h
qmgr_job.o: qmgr_job.c qmgr_job.o: qmgr_job.c

View File

@@ -176,6 +176,7 @@ struct QMGR_ENTRY_LIST {
}; };
struct QMGR_QUEUE { struct QMGR_QUEUE {
int dflags; /* delivery request options */
char *name; /* domain name or address */ char *name; /* domain name or address */
char *nexthop; /* domain name */ char *nexthop; /* domain name */
int todo_refcount; /* queue entries (todo list) */ int todo_refcount; /* queue entries (todo list) */

View File

@@ -148,6 +148,7 @@ static int qmgr_deliver_send_request(QMGR_ENTRY *entry, VSTREAM *stream)
} }
flags = message->tflags flags = message->tflags
| entry->queue->dflags
| (message->inspect_xport ? DEL_REQ_FLAG_BOUNCE : DEL_REQ_FLAG_DEFLT); | (message->inspect_xport ? DEL_REQ_FLAG_BOUNCE : DEL_REQ_FLAG_DEFLT);
attr_print(stream, ATTR_FLAG_MORE, attr_print(stream, ATTR_FLAG_MORE,
ATTR_TYPE_NUM, MAIL_ATTR_FLAGS, flags, ATTR_TYPE_NUM, MAIL_ATTR_FLAGS, flags,

View File

@@ -92,6 +92,7 @@
/* Global library. */ /* Global library. */
#include <mail_params.h> #include <mail_params.h>
#include <deliver_request.h> /* opportunistic session caching */
/* Application-specific. */ /* 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) QMGR_ENTRY *qmgr_entry_create(QMGR_PEER *peer, QMGR_MESSAGE *message)
{ {
char *myname = "qmgr_entry_create";
QMGR_ENTRY *entry; QMGR_ENTRY *entry;
QMGR_QUEUE *queue = peer->queue; 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); QMGR_LIST_APPEND(queue->todo, entry, queue_peers);
queue->todo_refcount++; 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 * Warn if a destination is falling behind while the active queue
* contains a non-trivial amount of single-recipient email. When a * contains a non-trivial amount of single-recipient email. When a

View File

@@ -181,6 +181,7 @@ void qmgr_queue_throttle(QMGR_QUEUE *queue, const char *reason)
queue->reason = mystrdup(reason); queue->reason = mystrdup(reason);
event_request_timer(qmgr_queue_unthrottle_wrapper, event_request_timer(qmgr_queue_unthrottle_wrapper,
(char *) queue, var_min_backoff_time); (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)); queue = (QMGR_QUEUE *) mymalloc(sizeof(QMGR_QUEUE));
qmgr_queue_count++; qmgr_queue_count++;
queue->dflags = 0;
queue->name = mystrdup(name); queue->name = mystrdup(name);
queue->nexthop = mystrdup(nexthop); queue->nexthop = mystrdup(nexthop);
queue->todo_refcount = 0; queue->todo_refcount = 0;

View File

@@ -29,7 +29,11 @@
/* After a successful mail transaction, a session may be saved /* After a successful mail transaction, a session may be saved
/* to the \fBscache(8)\fR session cache server, so that it /* to the \fBscache(8)\fR session cache server, so that it
/* may be used by any SMTP client for a subsequent transaction. /* 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 /* SECURITY
/* .ad /* .ad
/* .fi /* .fi
@@ -184,8 +188,11 @@
/* .PP /* .PP
/* Available in Postfix version 2.2 and later: /* Available in Postfix version 2.2 and later:
/* .IP "\fBsmtp_connection_cache_destinations (empty)\fR" /* .IP "\fBsmtp_connection_cache_destinations (empty)\fR"
/* The SMTP destinations for which SMTP connection caching is /* Permanently enable SMTP connection caching for the specified
/* enabled. /* 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" /* .IP "\fBsmtp_connection_cache_reuse_limit (10)\fR"
/* When SMTP session caching is enabled, the number of times that /* When SMTP session caching is enabled, the number of times that
/* an SMTP session is reused before it is closed. /* an SMTP session is reused before it is closed.
@@ -374,6 +381,7 @@ int var_smtp_cache_conn;
int var_smtp_reuse_limit; int var_smtp_reuse_limit;
char *var_smtp_cache_dest; char *var_smtp_cache_dest;
char *var_scache_service; char *var_scache_service;
bool var_smtp_cache_demand;
/* /*
* Global variables. smtp_errno is set by the address lookup routines and by * 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. * Session cache instance.
*/ */
if (*var_smtp_cache_dest) if (*var_smtp_cache_dest || var_smtp_cache_demand)
#if 0 #if 0
smtp_scache = scache_multi_create(); smtp_scache = scache_multi_create();
#else #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_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_DEFER_MXADDR, DEF_SMTP_DEFER_MXADDR, &var_smtp_defer_mxaddr,
VAR_SMTP_SEND_XFORWARD, DEF_SMTP_SEND_XFORWARD, &var_smtp_send_xforward, 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, 0,
}; };

View File

@@ -521,10 +521,14 @@ int smtp_connect(SMTP_STATE *state)
* :port, because : is already used for maptype:mapname. Because of * :port, because : is already used for maptype:mapname. Because of
* this limitation we use the bare domain without the optional [] or * this limitation we use the bare domain without the optional [] or
* non-default TCP port. * 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 if (cpp == sites->argv
&& smtp_cache_dest && ((request->flags & DEL_REQ_FLAG_SCACHE) != 0
&& string_list_match(smtp_cache_dest, domain)) { || (smtp_cache_dest && string_list_match(smtp_cache_dest, domain)))) {
sess_flags |= SMTP_SESS_FLAG_CACHE; sess_flags |= SMTP_SESS_FLAG_CACHE;
SET_NEXTHOP_STATE(state, lookup_mx, domain, port); SET_NEXTHOP_STATE(state, lookup_mx, domain, port);
} }

View File

@@ -39,6 +39,12 @@
/* Speak LMTP rather than SMTP. /* Speak LMTP rather than SMTP.
/* .IP "\fB-m \fImessage_count\fR" /* .IP "\fB-m \fImessage_count\fR"
/* Send the specified number of messages (default: 1). /* 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" /* .IP "\fB-r \fIrecipient_count\fR"
/* Send the specified number of recipients per transaction (default: 1). /* Send the specified number of recipients per transaction (default: 1).
/* Recipient names are generated by prepending a number to the /* 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 fixed_delay = 0;
static int talk_lmtp = 0; static int talk_lmtp = 0;
static char *subject = 0; static char *subject = 0;
static int number_rcpts = 0;
static void enqueue_connect(SESSION *); static void enqueue_connect(SESSION *);
static void start_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) if ((except = vstream_setjmp(session->stream)) != 0)
msg_fatal("%s while sending recipient", exception_text(except)); 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>", command(session->stream, "RCPT TO:<%d%s>",
session->rcpt_count, recipient); number_rcpts ? number_rcpts++ : session->rcpt_count,
recipient);
else else
command(session->stream, "RCPT TO:<%s>", recipient); command(session->stream, "RCPT TO:<%s>", recipient);
session->rcpt_count--; session->rcpt_count--;
@@ -767,7 +775,7 @@ static void quit_done(int unused_event, char *context)
static void usage(char *myname) 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 */ /* main - parse JCL and start the machine */
@@ -789,7 +797,7 @@ int main(int argc, char **argv)
/* /*
* Parse JCL. * 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) { switch (ch) {
case 'c': case 'c':
count++; count++;
@@ -822,6 +830,9 @@ int main(int argc, char **argv)
if ((message_count = atoi(optarg)) <= 0) if ((message_count = atoi(optarg)) <= 0)
msg_fatal("bad message count: %s", optarg); msg_fatal("bad message count: %s", optarg);
break; break;
case 'N':
number_rcpts = 1;
break;
case 'o': case 'o':
send_helo_first = 0; send_helo_first = 0;
send_headers = 0; send_headers = 0;