From: Marko Kreen Date: Wed, 21 Apr 2010 10:08:57 +0000 (+0000) Subject: Make listen(2) backlog argument configurable. X-Git-Tag: pgbouncer_1_3_3~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=52ae447b581b8291cd8512087322b2c4da2bb58c;p=pgbouncer Make listen(2) backlog argument configurable. --- diff --git a/doc/config.txt b/doc/config.txt index f6aee6b..de60817 100644 --- a/doc/config.txt +++ b/doc/config.txt @@ -341,6 +341,13 @@ large. Default: 2048 +==== listen_backlog ==== + +Backlog argument for listen(2). Determines how many new unanswered connection +attempts are kept in queue. When queue is full, futher new connections are dropped. + +Default: 128 + ==== sbuf_loopcnt ==== How many times to process data on one connection, before proceeding. diff --git a/etc/pgbouncer.ini b/etc/pgbouncer.ini index 685f1cf..874b639 100644 --- a/etc/pgbouncer.ini +++ b/etc/pgbouncer.ini @@ -162,6 +162,9 @@ log_pooler_errors = 1 ;; buffer for streaming packets ;pkt_buf = 2048 +;; man 2 listen +;listen_backlog = 128 + ;; networking options, for info: man 7 tcp ;; linux: notify program about new connection only if there diff --git a/include/bouncer.h b/include/bouncer.h index 44a5123..02c621a 100644 --- a/include/bouncer.h +++ b/include/bouncer.h @@ -310,6 +310,7 @@ extern char *cf_syslog_facility; extern char *cf_unix_socket_dir; extern char *cf_listen_addr; extern int cf_listen_port; +extern int cf_listen_backlog; extern int cf_pool_mode; extern int cf_max_client_conn; diff --git a/src/main.c b/src/main.c index 33668bc..bbfdb7b 100644 --- a/src/main.c +++ b/src/main.c @@ -64,6 +64,7 @@ char *cf_config_file = ""; char *cf_listen_addr = NULL; int cf_listen_port = 6432; +int cf_listen_backlog = 128; #ifndef WIN32 char *cf_unix_socket_dir = "/tmp"; #else @@ -142,6 +143,7 @@ ConfElem bouncer_params[] = { {"pidfile", false, CF_STR, &cf_pidfile}, {"listen_addr", false, CF_STR, &cf_listen_addr}, {"listen_port", false, CF_INT, &cf_listen_port}, +{"listen_backlog", false, CF_INT, &cf_listen_backlog}, #ifndef WIN32 {"unix_socket_dir", false, CF_STR, &cf_unix_socket_dir}, #endif diff --git a/src/pooler.c b/src/pooler.c index c13c955..760e3bf 100644 --- a/src/pooler.c +++ b/src/pooler.c @@ -194,7 +194,7 @@ static int create_net_socket(const char *listen_addr, int listen_port) tune_socket(sock, false); /* make it accept connections */ - res = listen(sock, 100); + res = listen(sock, cf_listen_backlog); if (res < 0) fatal_perror("listen");