cmd-idle.c revision 9691078006cfe7af5847116b519a0201c197a947
/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
#include "imap-common.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "crc32.h"
#include "mail-storage-settings.h"
#include "imap-commands.h"
#include "imap-sync.h"
#include <stdlib.h>
struct cmd_idle_context {
struct client_command_context *cmd;
struct imap_sync_context *sync_ctx;
struct timeout *keepalive_to;
unsigned int manual_cork:1;
unsigned int sync_pending:1;
};
static void
{
/* we're here only in connection failure cases */
}
if (done_ok)
else
if (free_cmd)
}
{
char *line;
case -1:
/* disconnected */
return;
case -2:
return;
}
/* we're still sending output to client. wait until it's all
sent so we don't lose any changes. */
return;
}
if (client->input_skip_line)
else {
break;
}
}
if (!client->disconnected)
}
{
if (client->disconnected)
}
{
/* it's busy sending output */
return;
}
also catches dead connections. */
/* 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 */
}
{
}
{
else {
if (client->disconnected)
}
}
{
if (interval == 0)
return;
}
{
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. */
return FALSE;
}
if (ctx->manual_cork) {
}
return TRUE;
}
/* input is pending */
}
return FALSE;
}
{
struct cmd_idle_context *ctx;
const struct mail_storage_settings *set;
idle_callback, ctx);
}
/* check immediately if there are changes. if they came before we
added mailbox-notifier, we wouldn't see them otherwise. */
return FALSE;
}