2
0
mirror of https://github.com/vdukhovni/postfix synced 2025-09-02 07:05:27 +00:00

postfix-2.2-20040721

This commit is contained in:
Wietse Venema
2004-07-21 00:00:00 -05:00
committed by Viktor Dukhovni
parent a360b3aff1
commit 2e9bf3b2a0
17 changed files with 201 additions and 90 deletions

View File

@@ -9567,6 +9567,13 @@ Apologies for any names omitted.
test the effects of collisions in the time or in name space
domains. File: global/scache.c.
20040721
Feature: the session cache server now logs cache hit and
miss statistics every $session_cache_status_update_time
seconds (default: 600s), as well as upon process exit.
File: scache/scache.c.
Open problems:
Low: update events.c so that 1-second timer requests do

View File

@@ -7,6 +7,14 @@ snapshot release). Patches are issued for the official release
and change the patchlevel and the release date. Patches are never
issued for snapshot releases.
Major changes with snapshot Postfix-2.2-20040721
================================================
The session cache manager now logs cache hit and miss statistics
every $session_cache_status_update_time seconds (default: 600s).
It reports the hit and miss rates for lookups by domain, as well
as for lookups by network address.
Incompatible changes with snapshot Postfix-2.2-20040720
=======================================================
@@ -18,7 +26,7 @@ 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
the same session for another mail transaction.
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.
@@ -69,7 +77,8 @@ specified.
Limitations:
- SMTP session caching does not work with TLS (the necessary support
for object passivation and re-activation does not exist).
for object passivation and re-activation does not exist without
closing the connection).
- SMTP session caching assumes that SASL credentials are valid for
all hostnames or domain names that map onto the same IP address

View File

@@ -5038,6 +5038,16 @@ The default time unit is s (seconds).
maintains a limited pool of cached sessions. </p>
</DD>
<DT><b><a name="session_cache_status_update_time">session_cache_status_update_time</a>
(default: 600s)</b></DT><DD>
<p> How frequently the <a href="scache.8.html">scache(8)</a> server logs usage statistics with
session cache hit and miss rates for logical destinations and for
physical endpoints. </p>
</DD>
<DT><b><a name="session_cache_ttl_limit">session_cache_ttl_limit</a>

View File

@@ -98,6 +98,12 @@ SCACHE(8) SCACHE(8)
The maximal time-to-live value that the session
cache server allows.
<b>session_cache_status_update_time (600s)</b>
How frequently the <a href="scache.8.html">scache(8)</a> server logs usage
statistics with session cache hit and miss rates
for logical destinations and for physical end-
points.
<b>MISCELLANEOUS CONTROLS</b>
<b><a href="postconf.5.html#config_directory">config_directory</a> (see 'postconf -d' output)</b>
The default location of the Postfix main.cf and

View File

@@ -67,8 +67,9 @@ SMTP(8) SMTP(8)
<b>BUGS</b>
SMTP session caching does not work with TLS. The necessary
support for object passivation and re-activation does not
exist.
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

View File

@@ -2639,6 +2639,10 @@ The default time unit is s (seconds).
.SH session_cache_service (default: scache)
The name of the scache(8) session cache service. This service
maintains a limited pool of cached sessions.
.SH session_cache_status_update_time (default: 600s)
How frequently the scache(8) server logs usage statistics with
session cache hit and miss rates for logical destinations and for
physical endpoints.
.SH session_cache_ttl_limit (default: 2s)
The maximal time-to-live value that the session cache server
allows. Requests that specify a larger TTL will be stored with the

View File

@@ -100,6 +100,10 @@ postconf(5) for more details including examples.
.IP "\fBsession_cache_ttl_limit (2s)\fR"
The maximal time-to-live value that the session cache server
allows.
.IP "\fBsession_cache_status_update_time (600s)\fR"
How frequently the scache(8) server logs usage statistics with
session cache hit and miss rates for logical destinations and for
physical endpoints.
.SH "MISCELLANEOUS CONTROLS"
.na
.nf

View File

@@ -71,8 +71,8 @@ other trouble.
.ad
.fi
SMTP session caching does not work with TLS. The necessary
support for object passivation and re-activation does not
exist.
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 address and TCP port.

View File

@@ -6928,3 +6928,9 @@ allows. Requests that specify a larger TTL will be stored with the
maximum allowed TTL. The purpose of this additional control is to
protect the infrastructure against careless people. The cache TTL
is already bounded by $max_idle. </p>
%PARAM session_cache_status_update_time 600s
<p> How frequently the scache(8) server logs usage statistics with
session cache hit and miss rates for logical destinations and for
physical endpoints. </p>

View File

@@ -1799,6 +1799,10 @@ extern char *var_scache_service;
#define DEF_SCACHE_TTL_LIM "2s"
extern int var_scache_ttl_lim;
#define VAR_SCACHE_STAT_TIME "session_cache_status_update_time"
#define DEF_SCACHE_STAT_TIME "600s"
extern int var_scache_stat_time;
/*
* Address verification service.
*/

View File

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

View File

@@ -43,7 +43,7 @@
/* The code maintains two types of association: a) physical
/* endpoint to file descriptor, and b) logical endpoint
/* to physical endpoint. Physical endpoints are stored and
/* look up under their low-level session details such as
/* looked up under their low-level session details such as
/* numerical addresses, while logical endpoints are stored
/* and looked up by the domain name that humans use. One logical
/* endpoint can refer to multiple physical endpoints, one
@@ -153,8 +153,8 @@
* Driver program for cache regression tests. Although all variants are
* relatively simple to verify by hand for single session storage, more
* sophisticated instrumentation is needed to demonstrate that the
* multi-sessin cache manager properly handles collisions in the time domain
* and in the various name space domains.
* multi-session cache manager properly handles collisions in the time
* domain and in all the name space domains.
*/
static SCACHE *scache;
static VSTRING *endp_prop;

View File

@@ -23,9 +23,6 @@
/* Idle time after which the client disconnects.
/* .IP ttl_limit
/* Upper bound on the time that a connection is allowed to persist.
/* .IP endp_ttl
/* How long the session should be cached. When information
/* expires it is purged automatically.
/* DIAGNOSTICS
/* Fatal error: memory allocation problem;
/* panic: internal consistency failure.

View File

@@ -59,8 +59,8 @@
* destination hash table entry.
*
* Likewise, each endpoint has an entry in the endpoint hash table, and each
* endpoint->session binding is kept in a circular list under its hash table
* entry.
* endpoint->session binding is kept in a circular list under its endpoint
* hash table entry.
*
* We do not attempt to limit the number of destination or endpoint entries,
* nor do we attempt to limit the number of sessions. Doing so would require

View File

@@ -84,6 +84,10 @@
/* .IP "\fBsession_cache_ttl_limit (2s)\fR"
/* The maximal time-to-live value that the session cache server
/* allows.
/* .IP "\fBsession_cache_status_update_time (600s)\fR"
/* How frequently the scache(8) server logs usage statistics with
/* session cache hit and miss rates for logical destinations and for
/* physical endpoints.
/* MISCELLANEOUS CONTROLS
/* .ad
/* .fi
@@ -129,6 +133,7 @@
/* System library. */
#include <sys_defs.h>
#include <time.h>
/* Utility library. */
@@ -136,6 +141,7 @@
#include <iostuff.h>
#include <htable.h>
#include <ring.h>
#include <events.h>
/* Global library. */
@@ -154,6 +160,7 @@
* Tunable parameters.
*/
int var_scache_ttl_lim;
int var_scache_stat_time;
/*
* Request parameters.
@@ -169,6 +176,15 @@ static VSTRING *scache_endp_prop;
*/
static SCACHE *scache;
/*
* Statistics.
*/
static int scache_dest_hits;
static int scache_dest_miss;
static int scache_endp_hits;
static int scache_endp_miss;
time_t scache_start_time;
/*
* Silly little macros.
*/
@@ -235,6 +251,7 @@ static void scache_find_endp_service(VSTREAM *client_stream)
ATTR_TYPE_NUM, MAIL_ATTR_STATUS, SCACHE_STAT_FAIL,
ATTR_TYPE_STR, MAIL_ATTR_PROP, "",
ATTR_TYPE_END);
scache_endp_miss++;
return;
} else {
attr_print(client_stream, ATTR_FLAG_NONE,
@@ -246,11 +263,12 @@ static void scache_find_endp_service(VSTREAM *client_stream)
msg_warn("%s: cannot send file descriptor: %m", myname);
if (close(fd) < 0)
msg_warn("close(%d): %m", fd);
scache_endp_hits++;
return;
}
}
/* scache_save_dest_service - protocol to save destiation->endpoint binding */
/* scache_save_dest_service - protocol to save destination->endpoint binding */
static void scache_save_dest_service(VSTREAM *client_stream)
{
@@ -308,6 +326,7 @@ static void scache_find_dest_service(VSTREAM *client_stream)
ATTR_TYPE_STR, MAIL_ATTR_PROP, "",
ATTR_TYPE_STR, MAIL_ATTR_PROP, "",
ATTR_TYPE_END);
scache_dest_miss++;
return;
} else {
attr_print(client_stream, ATTR_FLAG_NONE,
@@ -320,6 +339,7 @@ static void scache_find_dest_service(VSTREAM *client_stream)
msg_warn("%s: cannot send file descriptor: %m", myname);
if (close(fd) < 0)
msg_warn("close(%d): %m", fd);
scache_dest_hits++;
return;
}
}
@@ -364,6 +384,40 @@ static void scache_service(VSTREAM *client_stream, char *unused_service,
vstream_fflush(client_stream);
}
/* scache_status_dump - log and reset cache statistics */
static void scache_status_dump(char *unused_name, char **unused_argv)
{
if (scache_dest_hits || scache_dest_miss
|| scache_endp_hits || scache_endp_miss)
msg_info("statistics: start interval %.15s",
ctime(&scache_start_time) + 4);
if (scache_dest_hits || scache_dest_miss) {
msg_info("statistics: domain lookup hits=%d miss=%d success=%d%%",
scache_dest_hits, scache_dest_miss,
scache_dest_hits * 100
/ (scache_dest_hits + scache_dest_miss));
scache_dest_hits = scache_dest_miss = 0;
}
if (scache_endp_hits || scache_endp_miss) {
msg_info("statistics: address lookup hits=%d miss=%d success=%d%%",
scache_endp_hits, scache_endp_miss,
scache_endp_hits * 100
/ (scache_endp_hits + scache_endp_miss));
scache_endp_hits = scache_endp_miss = 0;
}
scache_start_time = event_time();
}
/* scache_status_update - log and reset cache statistics periodically */
static void scache_status_update(int unused_event, char *context)
{
scache_status_dump((char *) 0, (char **) 0);
event_request_timer(scache_status_update, context, var_scache_stat_time);
}
/* post_jail_init - initialization after privilege drop */
static void post_jail_init(char *unused_name, char **unused_argv)
@@ -388,6 +442,12 @@ static void post_jail_init(char *unused_name, char **unused_argv)
* connected for $idle_limit time units.
*/
var_use_limit = 0;
/*
* Dump and reset cache statistics every so often.
*/
event_request_timer(scache_status_update, (char *) 0, var_scache_stat_time);
scache_start_time = event_time();
}
/* main - pass control to the multi-threaded skeleton */
@@ -396,12 +456,14 @@ int main(int argc, char **argv)
{
static CONFIG_TIME_TABLE time_table[] = {
VAR_SCACHE_TTL_LIM, DEF_SCACHE_TTL_LIM, &var_scache_ttl_lim, 1, 0,
VAR_SCACHE_STAT_TIME, DEF_SCACHE_STAT_TIME, &var_scache_stat_time, 1, 0,
0,
};
multi_server_main(argc, argv, scache_service,
MAIL_SERVER_TIME_TABLE, time_table,
MAIL_SERVER_POST_INIT, post_jail_init,
MAIL_SERVER_EXIT, scache_status_dump,
MAIL_SERVER_SOLITARY,
0);
}

View File

@@ -57,8 +57,8 @@
/* other trouble.
/* BUGS
/* SMTP session caching does not work with TLS. The necessary
/* support for object passivation and re-activation does not
/* exist.
/* 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 address and TCP port.

View File

@@ -582,6 +582,7 @@ int smtp_connect(SMTP_STATE *state)
if (++addr_count == var_smtp_mxaddr_limit)
next = 0;
if ((sess_flags & SMTP_SESS_FLAG_CACHE) == 0
|| addr->pref == domain_best_pref
|| (session = smtp_reuse_addr(state, addr, port)) == 0)
session = smtp_connect_addr(dest, addr, port, why, sess_flags);
if ((state->session = session) != 0) {