Skip to content

Commit

Permalink
login proxy: Don't leak connections if reconnect fails with "Host is …
Browse files Browse the repository at this point in the history
…down"

Double-disconnection was also attempting to close the same fd twice, but I
think that couldn't have happened before this leak was fixed.
  • Loading branch information
sirainen committed Sep 23, 2016
1 parent e5a55bb commit 666d85f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/login-common/login-proxy.c
Expand Up @@ -300,7 +300,8 @@ proxy_log_connect_error(struct login_proxy *proxy)
static void proxy_reconnect_timeout(struct login_proxy *proxy)
{
timeout_remove(&proxy->to);
(void)login_proxy_connect(proxy);
if (login_proxy_connect(proxy) < 0)
login_proxy_free(&proxy);
}

static bool proxy_try_reconnect(struct login_proxy *proxy)
Expand Down Expand Up @@ -482,8 +483,10 @@ static void login_proxy_disconnect(struct login_proxy *proxy)
i_stream_destroy(&proxy->server_input);
if (proxy->server_output != NULL)
o_stream_destroy(&proxy->server_output);
if (proxy->server_fd != -1)
if (proxy->server_fd != -1) {
net_disconnect(proxy->server_fd);
proxy->server_fd = -1;
}
}

static void login_proxy_free_final(struct login_proxy *proxy)
Expand Down

0 comments on commit 666d85f

Please sign in to comment.