/* Copyright (c) 2014-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "time-util.h"
#include "istream-private.h"
#include "istream-timeout.h"
struct timeout_istream {
unsigned int timeout_msecs;
bool update_timestamp;
};
bool close_parent)
{
if (close_parent)
}
{
}
{
unsigned int over_msecs;
int diff;
if (tstream->update_timestamp) {
/* we came here after a long-running code. timeouts are handled
before IOs, so wait for i_stream_read() to be called again
before assuming that we've timed out. */
return;
}
/* we haven't reached the read timeout yet, update it */
if (diff < 0)
diff = 0;
return;
}
}
{
/* make sure we get called again on the next ioloop run. this updates
the timeout to the timestamp where we actually would have wanted to
start waiting for more data (so if there is long-running code
outside the ioloop it's not counted) */
}
static ssize_t
{
if (ret < 0) {
/* failed */
"%s (opened %d secs ago)",
}
/* first read. add the timeout here instead of in init
in case the stream is created long before it's actually
read from. */
/* we read something, reset the timeout */
} else if (tstream->update_timestamp) {
}
return ret;
}
struct istream *
{
i_stream_get_fd(input), 0);
}