Skip to content

Commit 714081d

Browse files
committed
bugfix: memory leak might happen if nginx 1.1.14+ is used *and* (at least) libpq fails to connect to the remote database.
1 parent 5c37d2d commit 714081d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/ngx_postgres_upstream.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define DDEBUG 0
3131
#endif
3232

33+
#include <nginx.h>
3334
#include "ngx_postgres_ddebug.h"
3435
#include "ngx_postgres_module.h"
3536
#include "ngx_postgres_keepalive.h"
@@ -564,6 +565,12 @@ ngx_postgres_upstream_free_connection(ngx_log_t *log, ngx_connection_t *c,
564565
rev->closed = 1;
565566
wev->closed = 1;
566567

568+
#if defined(nginx_version) && (nginx_version >= 1001004)
569+
if (c->pool) {
570+
ngx_destroy_pool(c->pool);
571+
}
572+
#endif
573+
567574
ngx_free_connection(c);
568575
}
569576

0 commit comments

Comments
 (0)