Skip to content

Commit

Permalink
login-common: Add preproxy pool
Browse files Browse the repository at this point in the history
preproxy pool can be used to do allocations that are released
once proxying starts.
  • Loading branch information
cmouse authored and sirainen committed Mar 21, 2017
1 parent 9fe890f commit f61eac3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/login-common/client-common.c
Expand Up @@ -174,6 +174,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);
Expand Down Expand Up @@ -224,6 +225,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);
Expand Down
2 changes: 2 additions & 0 deletions src/login-common/client-common.h
Expand Up @@ -107,6 +107,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;

Expand Down
3 changes: 3 additions & 0 deletions src/login-common/login-proxy.c
Expand Up @@ -705,6 +705,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);
Expand Down

0 comments on commit f61eac3

Please sign in to comment.