]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: istream-timeout logs how long the stream was open if parent read fails with...
authorTimo Sirainen <tss@iki.fi>
Tue, 28 Oct 2014 04:48:29 +0000 (21:48 -0700)
committerTimo Sirainen <tss@iki.fi>
Tue, 28 Oct 2014 04:48:29 +0000 (21:48 -0700)
src/lib/istream-timeout.c

index 874ac7cb1dbe7ad3705d2345a758f625f1c195d6..7edd660ba6cdfe362a4fa4ef03d2acfa2ccb2365 100644 (file)
@@ -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;