imap-client.c revision 700f5298a28c60d19936c3c20a6e4ff7d588fd9c
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen/* If the last command took longer than this to run, log statistics on
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen where the time was spent. */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen#define IMAP_CLIENT_DISCONNECT_LOG_STATS_CMD_MIN_RUNNING_MSECS 1000
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenextern struct mail_storage_callbacks mail_storage_callbacks;
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenextern struct imap_client_vfuncs imap_client_vfuncs;
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenstruct imap_module_register imap_module_register = { 0 };
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenunsigned int imap_client_count = 0;
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainenstatic const char *client_command_state_names[CLIENT_COMMAND_STATE_DONE+1] = {
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen "wait-input",
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen "wait-output",
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen "wait-external",
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen "wait-unambiguity",
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenstatic void client_idle_timeout(struct client *client)
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen client_send_line(client, "* BYE Disconnected for inactivity.");
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen client_destroy(client, "Disconnected for inactivity");
return FALSE;
return TRUE;
return FALSE;
if (ident != NULL) {
return client;
bool cmd_ret;
i_unreached();
if (!cmd_ret) {
const char *error;
const char *wait_condition,
unsigned int msecs_in_ioloop;
if (buffered_size > 0)
const char *cond_str;
unsigned int msecs_since_cmd;
if (msecs_since_cmd > 0) {
T_BEGIN {
} T_END;
const char *msg)
switch (parse_error) {
case IMAP_PARSE_ERROR_NONE:
i_unreached();
int ret;
return TRUE;
return FALSE;
return FALSE;
unsigned int count, ...)
const char *str;
return FALSE;
for (i = 0; i < count; i++) {
return i == count;
static struct client_command_context *
return cmd;
return NULL;
return TRUE;
return TRUE;
return FALSE;
return TRUE;
return TRUE;
return FALSE;
if (broken_client) {
return TRUE;
return cmd;
static struct client_command_context *
return cmd;
unsigned int unfinished_count = 0;
i_unreached();
return TRUE;
return FALSE;
return FALSE;
return TRUE;
if (!ret)
const unsigned char *data;
for (i = 0; i < data_size; i++) {
return FALSE;
return TRUE;
return TRUE;
return TRUE;
return FALSE;
return TRUE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
T_BEGIN {
} T_END;
if (ret)
if (remove_io)
if (!handled_commands)
return FALSE;
return TRUE;
bool finished;
if (!finished)
int ret;
return ret;
return FALSE;
return TRUE;
int ret;
if (ret == 0) {
if (ret < 0) {
return ret;
struct imap_search_update *
unsigned int *idx_r)
unsigned int i, count;
return NULL;
for (i = 0; i < count; i++) {
*idx_r = i;
return &updates[i];
return NULL;
void clients_destroy_all(void)