Skip to content

Commit

Permalink
lib-imap-client: Do not reset ips when reconnecting
Browse files Browse the repository at this point in the history
Avoids infinite loop
  • Loading branch information
cmouse authored and sirainen committed Apr 6, 2017
1 parent 1b7b0f7 commit 0816664
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/lib-imap-client/imapc-connection.c
Expand Up @@ -373,18 +373,17 @@ static void imapc_connection_set_state(struct imapc_connection *conn,
i_free_and_null(conn->disconnect_reason);
}
reply.text_without_resp = reply.text_full;
if (!conn->reconnecting)
if (!conn->reconnecting) {
imapc_login_callback(conn, &reply);

i_free(conn->ips);
conn->ips_count = 0;
}
conn->idling = FALSE;
conn->idle_plus_waiting = FALSE;
conn->idle_stopping = FALSE;

conn->selecting_box = NULL;
conn->selected_box = NULL;

i_free(conn->ips);
conn->ips_count = 0;
break;
default:
break;
Expand Down Expand Up @@ -1830,8 +1829,9 @@ void imapc_connection_connect(struct imapc_connection *conn,
dns_set.timeout_msecs = conn->client->set.connect_timeout_msecs;

imapc_connection_set_state(conn, IMAPC_CONNECTION_STATE_CONNECTING);
if (conn->ips_count == 0 &&
net_addr2ip(conn->client->set.host, &ip) == 0) {
if (conn->ips_count > 0) {
/* do nothing */
} else if (net_addr2ip(conn->client->set.host, &ip) == 0) {
conn->ips_count = 1;
conn->ips = i_new(struct ip_addr, conn->ips_count);
conn->ips[0] = ip;
Expand All @@ -1848,15 +1848,13 @@ void imapc_connection_connect(struct imapc_connection *conn,
conn->ips_count = ips_count;
conn->ips = i_new(struct ip_addr, ips_count);
memcpy(conn->ips, ips, ips_count * sizeof(*ips));
}

if (conn->ips_count == 0) {
} else {
(void)dns_lookup(conn->client->set.host, &dns_set,
imapc_connection_dns_callback, conn,
&conn->dns_lookup);
} else {
imapc_connection_connect_next_ip(conn);
return;
}
imapc_connection_connect_next_ip(conn);
}

void imapc_connection_input_pending(struct imapc_connection *conn)
Expand Down

0 comments on commit 0816664

Please sign in to comment.