From: Timo Sirainen Date: Tue, 28 Oct 2014 04:48:29 +0000 (-0700) Subject: lib: istream-timeout logs how long the stream was open if parent read fails with... X-Git-Tag: 2.2.16.rc1~269 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=decdff03c32cb5d0e99d71c5678fd008714de70b;p=thirdparty%2Fdovecot%2Fcore.git lib: istream-timeout logs how long the stream was open if parent read fails with ECONNRESET/EPIPE. --- diff --git a/src/lib/istream-timeout.c b/src/lib/istream-timeout.c index 874ac7cb1d..7edd660ba6 100644 --- a/src/lib/istream-timeout.c +++ b/src/lib/istream-timeout.c @@ -11,6 +11,7 @@ struct timeout_istream { struct timeout *to; struct timeval last_read_timestamp; + time_t created; unsigned int timeout_msecs; bool update_timestamp; @@ -75,6 +76,13 @@ i_stream_timeout_read(struct istream_private *stream) ret = i_stream_read_copy_from_parent(&stream->istream); if (ret < 0) { /* failed */ + if (errno == ECONNRESET || errno == EPIPE) { + int diff = ioloop_time - tstream->created; + + io_stream_set_error(&tstream->istream.iostream, + "%s (opened %d secs ago)", + i_stream_get_error(stream->parent), diff); + } } else if (tstream->to == NULL) { /* first read. add the timeout here instead of in init in case the stream is created long before it's actually @@ -111,6 +119,7 @@ i_stream_create_timeout(struct istream *input, unsigned int timeout_msecs) tstream->timeout_msecs = timeout_msecs; tstream->istream.max_buffer_size = input->real_stream->max_buffer_size; tstream->istream.stream_size_passthrough = TRUE; + tstream->created = ioloop_time; tstream->istream.read = i_stream_timeout_read; tstream->istream.switch_ioloop = i_stream_timeout_switch_ioloop;