]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Keep list of the SSL proxies, so they're deinitialized properly if we have
authorTimo Sirainen <tss@iki.fi>
Sun, 23 Feb 2003 10:45:46 +0000 (12:45 +0200)
committerTimo Sirainen <tss@iki.fi>
Sun, 23 Feb 2003 10:45:46 +0000 (12:45 +0200)
to kill them.

--HG--
branch : HEAD

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

index 5c7af2b0151d165ef7988a510bf0a40ea7a0f113..24275af5bfff930b7a4ca6796b4359752f7ef9c9 100644 (file)
@@ -212,12 +212,12 @@ static void main_deinit(void)
        if (io_listen != NULL) io_remove(io_listen);
        if (io_ssl_listen != NULL) io_remove(io_ssl_listen);
 
+       ssl_proxy_deinit();
+
        clients_deinit();
        master_deinit();
        auth_connection_deinit();
 
-       ssl_proxy_deinit();
-
        closelog();
 }
 
index b8c89184e3ff8e0409989620dddb80845bdc4355..5a59a5ede567369e5d676b85ad7a06f42d9cd9ca 100644 (file)
@@ -37,6 +37,7 @@ struct ssl_proxy {
 };
 
 static SSL_CTX *ssl_ctx;
+static struct hash_table *ssl_proxies;
 
 static void plain_read(struct ssl_proxy *proxy);
 static void plain_write(struct ssl_proxy *proxy);
@@ -317,6 +318,7 @@ int ssl_proxy_new(int fd)
        }
 
         main_ref();
+       hash_insert(ssl_proxies, proxy, proxy);
        return sfd[1];
 }
 
@@ -325,6 +327,8 @@ static int ssl_proxy_destroy(struct ssl_proxy *proxy)
        if (--proxy->refcount > 0)
                return TRUE;
 
+       hash_remove(ssl_proxies, proxy);
+
        SSL_free(proxy->ssl);
 
        (void)net_disconnect(proxy->fd_ssl);
@@ -375,13 +379,25 @@ void ssl_proxy_init(void)
                        keyfile, ssl_last_error());
        }
 
+        ssl_proxies = hash_create(default_pool, default_pool, 0, NULL, NULL);
        ssl_initialized = TRUE;
 }
 
+static void ssl_proxy_destroy_hash(void *key __attr_unused__, void *value,
+                                  void *context __attr_unused__)
+{
+       ssl_proxy_destroy(value);
+}
+
 void ssl_proxy_deinit(void)
 {
-       if (ssl_initialized)
-                SSL_CTX_free(ssl_ctx);
+       if (!ssl_initialized)
+               return;
+
+       SSL_CTX_free(ssl_ctx);
+
+       hash_foreach(ssl_proxies, ssl_proxy_destroy_hash, NULL);
+       hash_destroy(ssl_proxies);
 }
 
 #endif