]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Refcounting fixes. Unexpectedly destroyed SSL connection could have left
authorTimo Sirainen <tss@iki.fi>
Fri, 9 Jul 2004 11:45:01 +0000 (14:45 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 9 Jul 2004 11:45:01 +0000 (14:45 +0300)
looping for a long time.

--HG--
branch : HEAD

src/login-common/ssl-proxy-openssl.c

index e416d33c6a094f65b8b32884ab326392fdee2045..d0a541b3d97e4976f3a8c95e5c6c81538a577974 100644 (file)
@@ -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__,