]> 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:00:57 +0000 (15:00 +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 2d13d4e1f0e923acf877def4db294aa7974aa69e..0d021551a6e335b66439de6b12830dc5c0cdf415 100644 (file)
@@ -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)
@@ -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)