Earlier today, On Tue, 26 Jun 2007, I wrote:
> I have implemented this (along with +include_defer for completeness) and
> committed the patch, which I'll also put below (against 4.67). Please
> test.
The patch was buggy. A better patch (now committed) is below.
Philip
--
Philip Hazel, University of Cambridge Computing Service.
*** src/match.c Tue Apr 17 14:06:39 2007
--- match.c Tue Jun 26 14:50:41 2007
***************
*** 444,449 ****
--- 444,451 ----
unsigned int *original_cache_bits = *cache_ptr;
BOOL include_unknown = FALSE;
BOOL ignore_unknown = FALSE;
+ BOOL include_defer = FALSE;
+ BOOL ignore_defer = FALSE;
uschar *list;
uschar *sss;
uschar *ot = NULL;
***************
*** 553,562 ****
}
}
! /* If the host item is "+include_unknown", remember it in case there's a
! subsequent failed reverse lookup. */
! else if (type == MCL_HOST)
{
if (Ustrcmp(ss, "+include_unknown") == 0)
{
--- 555,565 ----
}
}
! /* If the host item is "+include_unknown" or "+ignore_unknown", remember it
! in case there's a subsequent failed reverse lookup. There is similar
! processing for "defer". */
! else if (type == MCL_HOST && *ss == '+')
{
if (Ustrcmp(ss, "+include_unknown") == 0)
{
***************
*** 570,575 ****
--- 573,590 ----
include_unknown = FALSE;
continue;
}
+ if (Ustrcmp(ss, "+include_defer") == 0)
+ {
+ include_defer = TRUE;
+ ignore_defer = FALSE;
+ continue;
+ }
+ if (Ustrcmp(ss, "+ignore_defer") == 0)
+ {
+ ignore_defer = TRUE;
+ include_defer = FALSE;
+ continue;
+ }
}
/* Starting with ! specifies a negative item. It is theoretically possible
***************
*** 715,721 ****
else
{
! uschar *error;
switch ((func)(arg, ss, valueptr, &error))
{
case OK:
--- 730,736 ----
else
{
! uschar *error = NULL;
switch ((func)(arg, ss, valueptr, &error))
{
case OK:
***************
*** 724,729 ****
--- 739,757 ----
return yield;
case DEFER:
+ if (error == NULL)
+ error = string_sprintf("DNS lookup of %s deferred", ss);
+ if (ignore_defer)
+ {
+ HDEBUG(D_lists) debug_printf("%s: item ignored by +ignore_defer\n",
+ error);
+ break;
+ }
+ if (include_defer)
+ {
+ log_write(0, LOG_MAIN, "%s: accepted by +include_defer", error);
+ return OK;
+ }
goto DEFER_RETURN;
/* The ERROR return occurs when checking hosts, when either a forward
***************
*** 823,829 ****
--- 851,870 ----
return file_yield;
case DEFER:
+ if (error == NULL)
+ error = string_sprintf("DNS lookup of %s deferred", ss);
+ if (ignore_defer)
+ {
+ HDEBUG(D_lists) debug_printf("%s: item ignored by +ignore_defer\n",
+ error);
+ break;
+ }
(void)fclose(f);
+ if (include_defer)
+ {
+ log_write(0, LOG_MAIN, "%s: accepted by +include_defer", error);
+ return OK;
+ }
goto DEFER_RETURN;
case ERROR: /* host name lookup failed - this can only */