]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap-client: Make sure DNS lookups get aborted at disconnect.
authorTimo Sirainen <tss@iki.fi>
Thu, 6 Jun 2013 09:21:14 +0000 (12:21 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 6 Jun 2013 09:21:14 +0000 (12:21 +0300)
src/lib-imap-client/imapc-connection.c

index b5e769bc0ce93769291a56660260c81f81adf28f..22722a6cea9cf5dd61b38800bdacc09e22239971 100644 (file)
@@ -352,7 +352,7 @@ void imapc_connection_disconnect(struct imapc_connection *conn)
        bool reconnecting = conn->selected_box != NULL &&
                conn->selected_box->reconnecting;
 
-       if (conn->fd == -1)
+       if (conn->state == IMAPC_CONNECTION_STATE_DISCONNECTED)
                return;
 
        if (conn->client->set.debug)
@@ -366,14 +366,18 @@ void imapc_connection_disconnect(struct imapc_connection *conn)
                timeout_remove(&conn->to);
        if (conn->to_output != NULL)
                timeout_remove(&conn->to_output);
-       imap_parser_unref(&conn->parser);
-       io_remove(&conn->io);
+       if (conn->parser != NULL)
+               imap_parser_unref(&conn->parser);
+       if (conn->io != NULL)
+               io_remove(&conn->io);
        if (conn->ssl_iostream != NULL)
                ssl_iostream_unref(&conn->ssl_iostream);
-       i_stream_destroy(&conn->input);
-       o_stream_destroy(&conn->output);
-       net_disconnect(conn->fd);
-       conn->fd = -1;
+       if (conn->fd != -1) {
+               i_stream_destroy(&conn->input);
+               o_stream_destroy(&conn->output);
+               net_disconnect(conn->fd);
+               conn->fd = -1;
+       }
 
        imapc_connection_set_state(conn, IMAPC_CONNECTION_STATE_DISCONNECTED);
        imapc_connection_abort_commands(conn, NULL, reconnecting);