istream-timeout.c revision decdff03c32cb5d0e99d71c5678fd008714de70b
/* Copyright (c) 2014 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 {
struct istream_private istream;
struct timeval last_read_timestamp;
unsigned int timeout_msecs;
bool update_timestamp;
};
bool close_parent)
{
if (close_parent)
}
{
}
{
unsigned int msecs;
int diff;
/* we haven't reached the read timeout yet, update it */
if (diff < 0)
diff = 0;
return;
}
}
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 */
/* 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) */
} else if (tstream->update_timestamp) {
}
return ret;
}
struct istream *
{
struct timeout_istream *tstream;
}