]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: Add preproxy pool
authorAki Tuomi <aki.tuomi@dovecot.fi>
Thu, 9 Mar 2017 12:08:40 +0000 (14:08 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Sun, 19 Mar 2017 16:57:46 +0000 (18:57 +0200)
preproxy pool can be used to do allocations that are released
once proxying starts.

src/login-common/client-common.c
src/login-common/client-common.h
src/login-common/login-proxy.c

index 599a0e3e1112665cb30682dfcaa72bc1940eb731..7bb23831df1286b4b49b273c64ddf91582750df4 100644 (file)
@@ -172,6 +172,7 @@ client_create(int fd, bool ssl, pool_t pool,
        client->refcount = 1;
 
        client->pool = pool;
+       client->preproxy_pool = pool_alloconly_create(MEMPOOL_GROWING"preproxy pool", 256);
        client->set = set;
        client->ssl_set = ssl_set;
        p_array_init(&client->module_contexts, client->pool, 5);
@@ -222,6 +223,9 @@ void client_destroy(struct client *client, const char *reason)
                return;
        client->destroyed = TRUE;
 
+       if (client->preproxy_pool != NULL)
+               pool_unref(&client->preproxy_pool);
+
        if (!client->login_success && reason != NULL) {
                reason = t_strconcat(reason, " ",
                        client_get_extra_disconnect_reason(client), NULL);
index 4dc3db76220a70db13362dddb8e9e5ff035f6435..41eb9728d66ba45b025224ceca1587b98f28076c 100644 (file)
@@ -124,6 +124,8 @@ struct client_vfuncs {
 struct client {
        struct client *prev, *next;
        pool_t pool;
+       /* this pool gets free'd once proxying starts */
+       pool_t preproxy_pool;
        struct client_vfuncs v;
        struct client_vfuncs *vlast;
 
index 8ae7bdba7eea415a4f5abd41b1b750f526266ed8..80553e37862bd742ee7ba3a9a241da0ff576c9d8 100644 (file)
@@ -700,6 +700,9 @@ void login_proxy_detach(struct login_proxy *proxy)
        const unsigned char *data;
        size_t size;
 
+       if (proxy->client->preproxy_pool != NULL)
+               pool_unref(&proxy->client->preproxy_pool);
+
        i_assert(proxy->client_fd == -1);
        i_assert(proxy->server_input != NULL);
        i_assert(proxy->server_output != NULL);