changeset 21765:91b94ecaa39d

login-common: Add preproxy pool preproxy pool can be used to do allocations that are released once proxying starts.
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Thu, 09 Mar 2017 14:08:40 +0200
parents 04edf83cff79
children 494f0ac153a6
files src/login-common/client-common.c src/login-common/client-common.h src/login-common/login-proxy.c
diffstat 3 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/login-common/client-common.c	Sun Jan 29 01:03:00 2017 +0200
+++ b/src/login-common/client-common.c	Thu Mar 09 14:08:40 2017 +0200
@@ -174,6 +174,7 @@
 	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);
@@ -224,6 +225,9 @@
 		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);
--- a/src/login-common/client-common.h	Sun Jan 29 01:03:00 2017 +0200
+++ b/src/login-common/client-common.h	Thu Mar 09 14:08:40 2017 +0200
@@ -107,6 +107,8 @@
 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;
 
--- a/src/login-common/login-proxy.c	Sun Jan 29 01:03:00 2017 +0200
+++ b/src/login-common/login-proxy.c	Thu Mar 09 14:08:40 2017 +0200
@@ -705,6 +705,9 @@
 	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);