From: Timo Sirainen Date: Fri, 9 Jul 2004 11:45:01 +0000 (+0300) Subject: Refcounting fixes. Unexpectedly destroyed SSL connection could have left X-Git-Tag: 1.1.alpha1~3804 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae3b8adb3ab01c42efd2d2b6eb476ba4988e071e;p=thirdparty%2Fdovecot%2Fcore.git Refcounting fixes. Unexpectedly destroyed SSL connection could have left looping for a long time. --HG-- branch : HEAD --- diff --git a/src/login-common/ssl-proxy-openssl.c b/src/login-common/ssl-proxy-openssl.c index e416d33c6a..d0a541b3d9 100644 --- a/src/login-common/ssl-proxy-openssl.c +++ b/src/login-common/ssl-proxy-openssl.c @@ -368,6 +368,8 @@ int ssl_proxy_has_valid_client_cert(struct ssl_proxy *proxy) void ssl_proxy_free(struct ssl_proxy *proxy) { + if (!proxy->destroyed) + ssl_proxy_destroy(proxy); ssl_proxy_unref(proxy); } @@ -377,6 +379,19 @@ static int ssl_proxy_unref(struct ssl_proxy *proxy) return TRUE; i_assert(proxy->refcount == 0); + SSL_free(proxy->ssl); + i_free(proxy); + + main_unref(); + return FALSE; +} + +static void ssl_proxy_destroy(struct ssl_proxy *proxy) +{ + if (proxy->destroyed) + return; + proxy->destroyed = TRUE; + hash_remove(ssl_proxies, proxy); (void)net_disconnect(proxy->fd_ssl); @@ -391,19 +406,7 @@ static int ssl_proxy_unref(struct ssl_proxy *proxy) if (proxy->io_plain_write != NULL) io_remove(proxy->io_plain_write); - SSL_free(proxy->ssl); - i_free(proxy); - - main_unref(); - return FALSE; -} - -static void ssl_proxy_destroy(struct ssl_proxy *proxy) -{ - if (!proxy->destroyed) { - proxy->destroyed = TRUE; - ssl_proxy_unref(proxy); - } + ssl_proxy_unref(proxy); } static RSA *ssl_gen_rsa_key(SSL *ssl __attr_unused__,