]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login proxy: Don't leak connections if reconnect fails with "Host is down"
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 23 Sep 2016 11:59:33 +0000 (14:59 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 23 Sep 2016 12:01:37 +0000 (15:01 +0300)
Double-disconnection was also attempting to close the same fd twice, but I
think that couldn't have happened before this leak was fixed.

src/login-common/login-proxy.c

index 751cb2dd42affa3805f41aa4c9a22a4030413e16..7ccf1558e94c0e5ddd01d531521e735b64df01a9 100644 (file)
@@ -305,7 +305,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)
@@ -487,8 +488,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)