changeset 21887:960920ff9975

lib-imap-client: Remove io earlier to avoid hammering If connection has failed and reconnection is not yet possible, io has to be removed here, otherwise it will keep hammering the callback.
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Fri, 31 Mar 2017 11:01:15 +0300
parents f05cf964db76
children dffc319d8397
files src/lib-imap-client/imapc-connection.c
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-imap-client/imapc-connection.c	Fri Mar 31 10:58:47 2017 +0300
+++ b/src/lib-imap-client/imapc-connection.c	Fri Mar 31 11:01:15 2017 +0300
@@ -1603,6 +1603,8 @@
 {
 	const struct ip_addr *ip = &conn->ips[conn->prev_connect_idx];
 	int err;
+	if (conn->io != NULL)
+		io_remove(&conn->io);
 
 	err = net_geterror(conn->fd);
 	if (err != 0) {
@@ -1612,7 +1614,6 @@
 			strerror(err)), IMAPC_CONNECT_RETRY_WAIT_MSECS);
 		return;
 	}
-	io_remove(&conn->io);
 	conn->io = io_add(conn->fd, IO_READ, imapc_connection_input, conn);
 
 	if (conn->client->set.ssl_mode == IMAPC_CLIENT_SSL_MODE_IMMEDIATE) {