Permalink
Browse files

bugfix: memory leak might happen if nginx 1.1.14+ is used *and* (at l…

…east) libpq fails to connect to the remote database.
  • Loading branch information...
agentzh committed Jun 21, 2012
1 parent 5c37d2d commit 714081d7f726ea98e406bdf61fbd16d6e77e9994
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/ngx_postgres_upstream.c
@@ -30,6 +30,7 @@
#define DDEBUG 0
#endif
+#include <nginx.h>
#include "ngx_postgres_ddebug.h"
#include "ngx_postgres_module.h"
#include "ngx_postgres_keepalive.h"
@@ -564,6 +565,12 @@ ngx_postgres_upstream_free_connection(ngx_log_t *log, ngx_connection_t *c,
rev->closed = 1;
wev->closed = 1;
+#if defined(nginx_version) && (nginx_version >= 1001004)
+ if (c->pool) {
+ ngx_destroy_pool(c->pool);
+ }
+#endif
+
ngx_free_connection(c);
}

0 comments on commit 714081d

Please sign in to comment.