-/* $Cambridge: exim/src/src/transports/smtp.c,v 1.3 2005/01/04 10:00:45 ph10 Exp $ */
+/* $Cambridge: exim/src/src/transports/smtp.c,v 1.4 2005/01/04 16:36:28 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
#endif
{ "hosts_max_try", opt_int,
(void *)offsetof(smtp_transport_options_block, hosts_max_try) },
+ { "hosts_max_try_hardlimit", opt_int,
+ (void *)offsetof(smtp_transport_options_block, hosts_max_try_hardlimit) },
#ifdef SUPPORT_TLS
{ "hosts_nopass_tls", opt_stringptr,
(void *)offsetof(smtp_transport_options_block, hosts_nopass_tls) },
10*60, /* final timeout */
1024, /* size_addition */
5, /* hosts_max_try */
+ 50, /* hosts_max_try_hardlimit */
FALSE, /* allow_localhost */
FALSE, /* gethostbyname */
TRUE, /* dns_qualify_single */
int hosts_retry = 0;
int hosts_serial = 0;
int hosts_total = 0;
+int total_hosts_tried = 0;
address_item *addr;
BOOL expired = TRUE;
BOOL continuing = continue_hostname != NULL;
. If there are any addresses whose status is still DEFER, carry on to the
next host/IPaddress, unless we have tried the number of hosts given
- by hosts_max_try; otherwise return.
+ by hosts_max_try or hosts_max_try_hardlimit; otherwise return. Note that
+ there is some fancy logic for hosts_max_try that means its limit can be
+ overstepped in some circumstances.
If we get to the end of the list, all hosts have deferred at least one address,
or not reached their retry times. If delay_after_cutoff is unset, it requests a
int unexpired_hosts_tried = 0;
for (host = hostlist;
- host != NULL && unexpired_hosts_tried < ob->hosts_max_try;
+ host != NULL &&
+ unexpired_hosts_tried < ob->hosts_max_try &&
+ total_hosts_tried < ob->hosts_max_try_hardlimit;
host = nexthost)
{
int rc;
/* This is for real. If the host is expired, we don't count it for
hosts_max_retry. This ensures that all hosts must expire before an address
- is timed out. Otherwise, if we are about to hit the hosts_max_retry limit,
- check to see if there is a subsequent hosts with a different MX value. If
- so, make that the next host, and don't count this one. This is a heuristic
- to make sure that different MXs do get tried. With a normal kind of retry
- rule, they would get tried anyway when the earlier hosts were delayed, but
- if the domain has a "retry every time" type of rule - as is often used for
- the the very large ISPs, that won't happen. */
+ is timed out, unless hosts_max_try_hardlimit (which protects against
+ lunatic DNS configurations) is reached.
+
+ If the host is not expired and we are about to hit the hosts_max_retry
+ limit, check to see if there is a subsequent hosts with a different MX
+ value. If so, make that the next host, and don't count this one. This is a
+ heuristic to make sure that different MXs do get tried. With a normal kind
+ of retry rule, they would get tried anyway when the earlier hosts were
+ delayed, but if the domain has a "retry every time" type of rule - as is
+ often used for the the very large ISPs, that won't happen. */
else
{
/* Attempt the delivery. */
+ total_hosts_tried++;
rc = smtp_deliver(addrlist, host, host_af, port, interface, tblock,
expanded_hosts != NULL, &message_defer, FALSE);
maximum retry time for this host. This means we may try try all hosts,
ignoring the limit, when messages have been around for some time. This is
important because if we don't try all hosts, the address will never time
- out. */
+ out. NOTE: this does not apply to hosts_max_try_hardlimit. */
if ((rc == DEFER || some_deferred) && nexthost != NULL)
{
for (addr = addrlist; addr != NULL; addr = addr->next)
{
/* If host is not NULL, it means that we stopped processing the host list
- because of hosts_max_try. This means we need to behave as if some hosts were
- skipped because their retry time had not come. Specifically, this prevents
- the address from timing out. */
+ because of hosts_max_try or hosts_max_try_hardlimit. In the former case, this
+ means we need to behave as if some hosts were skipped because their retry
+ time had not come. Specifically, this prevents the address from timing out.
+ However, if we have hit hosts_max_try_hardlimit, we want to behave as if all
+ hosts were tried. */
if (host != NULL)
{
- DEBUG(D_transport)
- debug_printf("hosts_max_try limit caused some hosts to be skipped\n");
- setflag(addr, af_retry_skipped);
+ if (total_hosts_tried >= ob->hosts_max_try_hardlimit)
+ {
+ DEBUG(D_transport)
+ debug_printf("hosts_max_try_hardlimit reached: behave as if all "
+ "hosts were tried\n");
+ }
+ else
+ {
+ DEBUG(D_transport)
+ debug_printf("hosts_max_try limit caused some hosts to be skipped\n");
+ setflag(addr, af_retry_skipped);
+ }
}
if (queue_smtp) /* no deliveries attempted */