Module: kamailio Branch: master Commit: 66060a4462bfb2c3b06ed2053aa11849014b699c URL: https://github.com/kamailio/kamailio/commit/66060a4462bfb2c3b06ed2053aa11849014b699c
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2026-01-06T17:17:09+01:00 core: tcp - added global parameter tcp_listen_backlog - allows to set the value for tcp listen backlog --- Modified: src/core/cfg.lex Modified: src/core/cfg.y Modified: src/core/globals.h Modified: src/core/tcp_main.c --- Diff: https://github.com/kamailio/kamailio/commit/66060a4462bfb2c3b06ed2053aa11849014b699c.diff Patch: https://github.com/kamailio/kamailio/commit/66060a4462bfb2c3b06ed2053aa11849014b699c.patch --- diff --git a/src/core/cfg.lex b/src/core/cfg.lex index 3f20bccbb72..8404f4c90a7 100644 --- a/src/core/cfg.lex +++ b/src/core/cfg.lex @@ -441,6 +441,7 @@ TCP_OPT_KEEPIDLE "tcp_keepidle" TCP_OPT_KEEPINTVL "tcp_keepintvl" TCP_OPT_KEEPCNT "tcp_keepcnt" TCP_OPT_CRLF_PING "tcp_crlf_ping" +TCP_OPT_LISTEN_BACKLOG "tcp_listen_backlog" TCP_OPT_ACCEPT_NO_CL "tcp_accept_no_cl" TCP_OPT_ACCEPT_HEP3 "tcp_accept_hep3" TCP_OPT_ACCEPT_HAPROXY "tcp_accept_haproxy" @@ -963,6 +964,8 @@ IMPORTFILE "import_file" return TCP_OPT_KEEPCNT; } <INITIAL>{TCP_OPT_CRLF_PING} { count(); yylval.strval=yytext; return TCP_OPT_CRLF_PING; } +<INITIAL>{TCP_OPT_LISTEN_BACKLOG} { count(); yylval.strval=yytext; + return TCP_OPT_LISTEN_BACKLOG; } <INITIAL>{TCP_OPT_ACCEPT_NO_CL} { count(); yylval.strval=yytext; return TCP_OPT_ACCEPT_NO_CL; } <INITIAL>{TCP_OPT_ACCEPT_HEP3} { count(); yylval.strval=yytext; diff --git a/src/core/cfg.y b/src/core/cfg.y index e71907f72a3..2173585823c 100644 --- a/src/core/cfg.y +++ b/src/core/cfg.y @@ -472,6 +472,7 @@ extern char *default_routename; %token TCP_OPT_KEEPINTVL %token TCP_OPT_KEEPCNT %token TCP_OPT_CRLF_PING +%token TCP_OPT_LISTEN_BACKLOG %token TCP_OPT_ACCEPT_NO_CL %token TCP_OPT_ACCEPT_HEP3 %token TCP_OPT_ACCEPT_HAPROXY @@ -1428,6 +1429,14 @@ assign_stm: #endif } | TCP_OPT_CRLF_PING EQUAL error { yyerror("boolean value expected"); } + | TCP_OPT_LISTEN_BACKLOG EQUAL NUMBER { + #ifdef USE_TCP + ksr_tcp_listen_backlog=$3; + #else + warn("tcp support not compiled in"); + #endif + } + | TCP_OPT_LISTEN_BACKLOG EQUAL error { yyerror("number expected"); } | TCP_OPT_ACCEPT_NO_CL EQUAL NUMBER { #ifdef USE_TCP tcp_default_cfg.accept_no_cl=$3; diff --git a/src/core/globals.h b/src/core/globals.h index 8dee5e7cbc4..64fec0539e6 100644 --- a/src/core/globals.h +++ b/src/core/globals.h @@ -104,6 +104,7 @@ extern int tcp_disable; extern enum poll_types tcp_poll_method; extern int tcp_max_connections; /* maximum tcp connections, hard limit */ extern int tls_max_connections; /* maximum tls connections, hard limit */ +extern int ksr_tcp_listen_backlog; #endif extern int ksr_tcp_accept_hep3; extern int ksr_tcp_accept_haproxy; diff --git a/src/core/tcp_main.c b/src/core/tcp_main.c index 56417f57003..9fe7c849bc7 100644 --- a/src/core/tcp_main.c +++ b/src/core/tcp_main.c @@ -174,7 +174,7 @@ int tcp_max_connections = DEFAULT_TCP_MAX_CONNECTIONS; int tls_max_connections = DEFAULT_TLS_MAX_CONNECTIONS; int tcp_accept_unique = 0; int ksr_tcp_main_threads = 0; - +int ksr_tcp_listen_backlog = TCP_LISTEN_BACKLOG; int tcp_connection_match = TCPCONN_MATCH_DEFAULT; static union sockaddr_union tcp_source_ipv4_addr; /* saved bind/srv v4 addr. */ @@ -3358,7 +3358,7 @@ int tcp_init(struct socket_info *sock_info) } goto error; } - if(listen(sock_info->socket, TCP_LISTEN_BACKLOG) == -1) { + if(listen(sock_info->socket, ksr_tcp_listen_backlog) == -1) { LM_ERR("listen(%x, %p, %d) on %s: %s\n", sock_info->socket, &addr->s, (unsigned)sockaddru_len(*addr), sock_info->address_str.s, strerror(errno)); _______________________________________________ Kamailio - Development Mailing List -- [email protected] To unsubscribe send an email to [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender!
