/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
#include "imap-common.h"
#include "istream.h"
#include "ostream.h"
#include "crc32.h"
#include "mail-storage-settings.h"
#include "imap-commands.h"
#include "imap-keepalive.h"
#include "imap-sync.h"
struct cmd_idle_context {
};
static void
{
/* we're here only in connection failure cases */
}
if (done_ok)
else
if (free_cmd)
}
static bool
{
const char *line;
else {
free_cmd);
return TRUE;
}
}
return FALSE;
}
{
case -1:
/* disconnected */
return TRUE;
case -2:
return TRUE;
}
/* we're still sending output to client. wait until it's all
sent so we don't lose any changes. */
return FALSE;
}
}
{
if (idle_client_input_more(ctx)) {
if (client->disconnected)
else
}
}
{
/* it's busy sending output */
return;
}
Sending this also catches dead connections. Don't send
anything if there is already data waiting in output
buffer. */
}
/* Make sure idling connections don't get disconnected. There are
several clients that really want to IDLE forever and there's not
much harm in letting them do so. */
/* recalculate time for the next keepalive timeout */
}
{
/* hibernation can't happen while sync is running.
the timeout is added back afterwards. */
}
{
else {
if (client->disconnected)
}
}
{
if (interval == 0)
return;
interval);
}
{
if (imap_client_hibernate(&client)) {
/* client may be destroyed now */
} else {
/* failed - don't bother retrying */
}
}
{
if (secs == 0)
return;
ctx->to_hibernate =
}
{
return TRUE;
}
if (ctx->manual_cork) {
/* we're coming from idle_callback instead of a normal
I/O handler, so we'll have to do corking manually */
}
/* unfinished */
if (ctx->manual_cork) {
}
return FALSE;
}
}
}
if (ctx->sync_pending) {
/* more changes occurred while we were sending changes to
client.
NOTE: this recurses back to this function,
so we return here instead of doing everything twice. */
}
if (ctx->manual_cork) {
}
return TRUE;
}
/* input is pending. add the io back and mark the input as
pending. we can't safely read more input immediately here. */
}
return FALSE;
}
{
if (!client->state_import_idle_continue)
else {
/* continuing an IDLE after hibernation */
}
/* check immediately if there are changes. if they came before we
added mailbox-notifier, we wouldn't see them otherwise. */
}