Skip to content

Commit

Permalink
submission: Allocate each backend on its own pool.
Browse files Browse the repository at this point in the history
This allows allocating per-backend module data.
  • Loading branch information
stephanbosch committed Oct 29, 2018
1 parent 7017982 commit 83fd3b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/submission/submission-backend-relay.c
Expand Up @@ -992,9 +992,11 @@ submission_backend_relay_create(
struct mail_user *user = client->user;
struct ssl_iostream_settings ssl_set;
struct smtp_client_settings smtp_set;
pool_t pool;

backend = i_new(struct submission_backend_relay, 1);
submission_backend_init(&backend->backend, client,
pool = pool_alloconly_create("submission relay backend", 1024);
backend = p_new(pool, struct submission_backend_relay, 1);
submission_backend_init(&backend->backend, pool, client,
&backend_relay_vfuncs);

i_zero(&ssl_set);
Expand Down Expand Up @@ -1076,7 +1078,6 @@ static void backend_relay_destroy(struct submission_backend *_backend)
smtp_client_transaction_destroy(&backend->trans);
if (backend->conn != NULL)
smtp_client_connection_close(&backend->conn);
i_free(backend);
}

static void backend_relay_ready_cb(const struct smtp_reply *reply,
Expand Down
4 changes: 3 additions & 1 deletion src/submission/submission-backend.c
Expand Up @@ -11,9 +11,10 @@
#include "submission-backend.h"

void submission_backend_init(struct submission_backend *backend,
struct client *client,
pool_t pool, struct client *client,
const struct submission_backend_vfuncs *vfunc)
{
backend->pool = pool;
backend->client = client;
backend->v = *vfunc;

Expand All @@ -32,6 +33,7 @@ static void submission_backend_destroy(struct submission_backend *backend)

DLLIST_REMOVE(&client->backends, backend);
backend->v.destroy(backend);
pool_unref(&backend->pool);
}

void submission_backends_destroy_all(struct client *client)
Expand Down
3 changes: 2 additions & 1 deletion src/submission/submission-backend.h
Expand Up @@ -80,6 +80,7 @@ struct submission_backend_vfuncs {
};

struct submission_backend {
pool_t pool;
struct client *client;

struct submission_backend *prev, *next;
Expand All @@ -98,7 +99,7 @@ struct submission_backend {
};

void submission_backend_init(struct submission_backend *backend,
struct client *client,
pool_t pool, struct client *client,
const struct submission_backend_vfuncs *vfunc);
void submission_backends_destroy_all(struct client *client);

Expand Down

0 comments on commit 83fd3b1

Please sign in to comment.