-/* $Cambridge: exim/src/src/transports/pipe.c,v 1.2 2004/10/14 14:52:45 ph10 Exp $ */
+/* $Cambridge: exim/src/src/transports/pipe.c,v 1.6 2005/05/10 11:13:09 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2004 */
+/* Copyright (c) University of Cambridge 1995 - 2005 */
/* See the file NOTICE for conditions of use and distribution. */
(void *)offsetof(pipe_transport_options_block, temp_errors) },
{ "timeout", opt_time,
(void *)offsetof(pipe_transport_options_block, timeout) },
+ { "timeout_defer", opt_bool,
+ (void *)offsetof(pipe_transport_options_block, timeout_defer) },
{ "umask", opt_octint,
(void *)offsetof(pipe_transport_options_block, umask) },
{ "use_bsmtp", opt_bool,
FALSE, /* freeze_exec_fail */
FALSE, /* ignore_status */
FALSE, /* restrict_to_path */
+ FALSE, /* timeout_defer */
FALSE, /* use_shell */
FALSE, /* use_bsmtp */
FALSE /* use_crlf */
without reading all of it, we expect an EPIPE error, which should be ignored.
We used also to ignore WRITEINCOMPLETE but the writing function is now cleverer
at handling OS where the death of a pipe doesn't give EPIPE immediately. See
-comments therein. This change made 04-Sep-98. Clean up this code in a year or
-so. */
+comments therein. */
if (!written_ok)
{
if (errno == ETIMEDOUT)
+ {
+ addr->message = string_sprintf("%stimeout while writing to pipe",
+ transport_filter_timed_out? "transport filter " : "");
+ addr->transport_return = ob->timeout_defer? DEFER : FAIL;
timeout = 1;
- else if (errno == EPIPE /* || errno == ERRNO_WRITEINCOMPLETE */ )
+ }
+ else if (errno == EPIPE)
{
- debug_printf("transport error %s ignored\n",
- (errno == EPIPE)? "EPIPE" : "WRITEINCOMPLETE");
+ debug_printf("transport error EPIPE ignored\n");
}
else
{
- addr->transport_return = PANIC;
+ addr->transport_return = PANIC;
addr->basic_errno = errno;
if (errno == ERRNO_CHHEADER_FAIL)
addr->message =
if ((rc = child_close(pid, timeout)) != 0)
{
+ uschar *tmsg = (addr->message == NULL)? US"" :
+ string_sprintf(" (preceded by %s)", addr->message);
+
/* The process did not complete in time; kill its process group and fail
the delivery. It appears to be necessary to kill the output process too, as
otherwise it hangs on for some time if the actual pipe process is sleeping.
{
killpg(pid, SIGKILL);
kill(outpid, SIGKILL);
- addr->transport_return = FAIL;
- addr->message = string_sprintf("pipe delivery process timed out");
+ addr->transport_return = ob->timeout_defer? DEFER : FAIL;
+ addr->message = string_sprintf("pipe delivery process timed out%s", tmsg);
}
/* Wait() failed. */
{
addr->transport_return = PANIC;
addr->message = string_sprintf("Wait() failed for child process of %s "
- "transport: %s", tblock->name, strerror(errno));
+ "transport: %s%s", tblock->name, strerror(errno), tmsg);
}
/* Either the process completed, but yielded a non-zero (necessarily
{
addr->transport_return = FAIL;
addr->message = string_sprintf("Child process of %s transport (running "
- "command \"%s\") was terminated by signal %d (%s)", tblock->name, cmd,
- -rc, os_strsignal(-rc));
+ "command \"%s\") was terminated by signal %d (%s)%s", tblock->name, cmd,
+ -rc, os_strsignal(-rc), tmsg);
}
}
{
addr->transport_return = DEFER;
addr->special_action = SPECIAL_FREEZE;
- addr->message = string_sprintf("pipe process failed to exec \"%s\"",
- cmd);
+ addr->message = string_sprintf("pipe process failed to exec \"%s\"%s",
+ cmd, tmsg);
}
/* Otherwise take action only if not ignoring status */
if (quote)
addr->message = string_cat(addr->message, &size, &ptr, US"\"", 1);
}
+
+ /* Add previous filter timeout message, if present. */
+
+ if (*tmsg != 0)
+ addr->message = string_cat(addr->message, &size, &ptr, tmsg,
+ Ustrlen(tmsg));
+
addr->message[ptr] = 0; /* Ensure concatenated string terminated */
}
}