pgpool2.git / summary / log / commit / refs
commit ed14bc75f096e259f2193557df12b6e06fd2f1d3
Author: Tatsuo Ishii <ishii at sraoss.co.jp>
Date: Sat Nov 14 11:36:35 2009 +0000
Limit listen(2)'s backlog parameter to num_init_children*2 at largest.
This is almost same algorithm as PostgreSQL.
I hope pgpool-II does not consume so much system resource any more...
main.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/main.c b/main.c
index 7b2ac126f..ab047ee35 100644
--- a/main.c
+++ b/main.c
@@ -853,6 +853,7 @@ static int create_inet_domain_socket(const char *hostname, const int port)
int status;
int one = 1;
int len;
+ int backlog;
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd == -1)
@@ -902,7 +903,11 @@ static int create_inet_domain_socket(const char *hostname, const int port)
myexit(1);
}
- status = listen(fd, PGPOOLMAXLITSENQUEUELENGTH);
+ backlog = pool_config->num_init_children * 2;
+ if (backlog > PGPOOLMAXLITSENQUEUELENGTH)
+ backlog = PGPOOLMAXLITSENQUEUELENGTH;
+
+ status = listen(fd, backlog);
if (status < 0)
{
pool_error("listen() failed. reason: %s", strerror(errno));
[parent: 0c93c0044ea4]