Default: 2048
+==== sbuf_loopcnt ====
+
+How many times to process data on one connection, before proceeding.
+Without limit, one connection with big resultset can stall pgbouncer
+for a long time. One loop processes one `pkt_buf` amount of data.
+0 means no limit.
+
+Default: 5
+
==== tcp_defer_accept ====
Details about following options shouldbe looked from man 7 tcp
/* sbuf config */
int cf_sbuf_len = 2048;
+int cf_sbuf_loopcnt = 5;
int cf_tcp_socket_buffer = 0;
#if defined(TCP_DEFER_ACCEPT) || defined(SO_ACCEPTFILTER)
int cf_tcp_defer_accept = 1;
{"ignore_startup_parameters", true, CF_STR, &cf_ignore_startup_params},
{"pkt_buf", false, CF_INT, &cf_sbuf_len},
+{"sbuf_loopcnt", true, CF_INT, &cf_sbuf_loopcnt},
{"tcp_defer_accept", true, {cf_get_int, set_defer_accept}, &cf_tcp_defer_accept},
{"tcp_socket_buffer", true, CF_INT, &cf_tcp_socket_buffer},
{"tcp_keepalive", true, CF_INT, &cf_tcp_keepalive},
static void sbuf_main_loop(SBuf *sbuf, bool skip_recv)
{
unsigned free, ok;
+ int loopcnt = 0;
/* sbuf was closed before in this event loop */
if (!sbuf->sock)
goto skip_recv;
try_more:
+ /* avoid spending too much time on single socket */
+ if (cf_sbuf_loopcnt > 0 && loopcnt >= cf_sbuf_loopcnt) {
+ log_debug("loopcnt full");
+ return;
+ }
+ loopcnt++;
+
/* make room in buffer */
sbuf_try_resync(sbuf, false);