]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master: Use pooled memory for haproxy
authorAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 3 Oct 2017 08:15:54 +0000 (11:15 +0300)
committerTimo Sirainen <tss@dovecot.fi>
Mon, 16 Oct 2017 08:04:36 +0000 (11:04 +0300)
src/lib-master/master-service-haproxy.c

index a58cfc502b143d6e3acf593c38f6f5bceb3591e6..384b33772f7035c2aa4d12540caa6a22d7b24cf2 100644 (file)
@@ -66,6 +66,8 @@ struct haproxy_data_v2 {
 struct master_service_haproxy_conn {
        struct master_service_connection conn;
 
+       pool_t pool;
+
        struct master_service_haproxy_conn *prev, *next;
        
        struct master_service *service;
@@ -83,7 +85,7 @@ master_service_haproxy_conn_free(struct master_service_haproxy_conn *hpconn)
 
        io_remove(&hpconn->io);
        timeout_remove(&hpconn->to);
-       i_free(hpconn);
+       pool_unref(&hpconn->pool);
 }
 
 static void
@@ -492,6 +494,7 @@ void master_service_haproxy_new(struct master_service *service,
                                struct master_service_connection *conn)
 {
        struct master_service_haproxy_conn *hpconn;
+       pool_t pool;
 
        if (!master_service_haproxy_conn_is_trusted(service, conn)) {
                i_warning("haproxy: Client not trusted (rip=%s)",
@@ -500,7 +503,9 @@ void master_service_haproxy_new(struct master_service *service,
                return;
        }
 
-       hpconn = i_new(struct master_service_haproxy_conn, 1);
+       pool = pool_alloconly_create("haproxy connection", 128);
+       hpconn = p_new(pool, struct master_service_haproxy_conn, 1);
+       hpconn->pool = pool;
        hpconn->conn = *conn;
        hpconn->service = service;
        DLLIST_PREPEND(&service->haproxy_conns, hpconn);