struct imapc_client_connection **connp;
array_foreach_modifiable(&client->conns, connp) {
+ i_assert(imapc_connection_get_mailbox((*connp)->conn) == NULL);
imapc_connection_deinit(&(*connp)->conn);
i_free(*connp);
}
struct imapc_client_mailbox *box = *_box;
struct imapc_client_connection *const *connp;
+ box->closing = TRUE;
+
/* cancel any pending commands */
imapc_connection_unselect(box);
{
struct imapc_command *cmd;
+ i_assert(!box->closing);
+
cmd = imapc_connection_cmd(box->conn, callback, context);
imapc_command_set_mailbox(cmd, box);
return cmd;
{
struct imapc_client_mailbox *selected_box;
- if (imapc_connection_get_state(box->conn) != IMAPC_CONNECTION_STATE_DONE)
+ if (box->closing ||
+ imapc_connection_get_state(box->conn) != IMAPC_CONNECTION_STATE_DONE)
return FALSE;
selected_box = imapc_connection_get_mailbox(box->conn);
net_disconnect(conn->fd);
conn->fd = -1;
- imapc_connection_abort_commands(conn, TRUE, reconnecting);
imapc_connection_set_state(conn, IMAPC_CONNECTION_STATE_DISCONNECTED);
+ imapc_connection_abort_commands(conn, TRUE, reconnecting);
}
static void imapc_connection_set_disconnected(struct imapc_connection *conn)
{
- imapc_connection_abort_commands(conn, TRUE, FALSE);
imapc_connection_set_state(conn, IMAPC_CONNECTION_STATE_DISCONNECTED);
+ imapc_connection_abort_commands(conn, TRUE, FALSE);
}
static void imapc_connection_reconnect(struct imapc_connection *conn)
{
struct imapc_connection *conn = box->conn;
- imapc_connection_send_idle_done(conn);
- imapc_connection_abort_commands(conn, FALSE, FALSE);
-
if (conn->selected_box != NULL || conn->selecting_box != NULL) {
i_assert(conn->selected_box == box ||
conn->selecting_box == box);
conn->selected_box = NULL;
conn->selecting_box = NULL;
}
+ imapc_connection_send_idle_done(conn);
+ imapc_connection_abort_commands(conn, FALSE, FALSE);
}
struct imapc_client_mailbox *