Module: kamailio
Branch: master
Commit: 213e19108699ed4ea5c962caf673b0a60ce41480
URL:
https://github.com/kamailio/kamailio/commit/213e19108699ed4ea5c962caf673b0a…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-10-16T08:57:32+02:00
core: added tcp_msg_data_timeout parameter
- duration in seconds for how long to wait till data is received on a
new tcp connection
- default 20
---
Modified: src/core/cfg.lex
Modified: src/core/cfg.y
Modified: src/core/globals.h
Modified: src/core/tcp_init.h
Modified: src/core/tcp_main.c
Modified: src/main.c
---
Diff:
https://github.com/kamailio/kamailio/commit/213e19108699ed4ea5c962caf673b0a…
Patch:
https://github.com/kamailio/kamailio/commit/213e19108699ed4ea5c962caf673b0a…
---
diff --git a/src/core/cfg.lex b/src/core/cfg.lex
index 44c62279b7d..872e4084c17 100644
--- a/src/core/cfg.lex
+++ b/src/core/cfg.lex
@@ -367,6 +367,7 @@ MAXSNDBUFFER maxsndbuffer
SQL_BUFFER_SIZE sql_buffer_size
MSG_RECV_MAX_SIZE msg_recv_max_size
TCP_MSG_READ_TIMEOUT tcp_msg_read_timeout
+TCP_MSG_DATA_TIMEOUT tcp_msg_data_timeout
TCP_CHECK_TIMER tcp_check_timer
CHILDREN children
SOCKET socket
@@ -855,6 +856,7 @@ IMPORTFILE "import_file"
<INITIAL>{SQL_BUFFER_SIZE} { count(); yylval.strval=yytext; return SQL_BUFFER_SIZE;
}
<INITIAL>{MSG_RECV_MAX_SIZE} { count(); yylval.strval=yytext; return
MSG_RECV_MAX_SIZE; }
<INITIAL>{TCP_MSG_READ_TIMEOUT} { count(); yylval.strval=yytext; return
TCP_MSG_READ_TIMEOUT; }
+<INITIAL>{TCP_MSG_DATA_TIMEOUT} { count(); yylval.strval=yytext; return
TCP_MSG_DATA_TIMEOUT; }
<INITIAL>{TCP_CHECK_TIMER} { count(); yylval.strval=yytext; return TCP_CHECK_TIMER;
}
<INITIAL>{CHILDREN} { count(); yylval.strval=yytext; return CHILDREN; }
<INITIAL>{SOCKET} { count(); yylval.strval=yytext; return SOCKET; }
diff --git a/src/core/cfg.y b/src/core/cfg.y
index a5e16e259e1..ed6764d09fb 100644
--- a/src/core/cfg.y
+++ b/src/core/cfg.y
@@ -423,6 +423,7 @@ extern char *default_routename;
%token SQL_BUFFER_SIZE
%token MSG_RECV_MAX_SIZE
%token TCP_MSG_READ_TIMEOUT
+%token TCP_MSG_DATA_TIMEOUT
%token TCP_CHECK_TIMER
%token USER
%token GROUP
@@ -1020,6 +1021,8 @@ assign_stm:
| MSG_RECV_MAX_SIZE EQUAL error { yyerror("number expected"); }
| TCP_MSG_READ_TIMEOUT EQUAL NUMBER { ksr_tcp_msg_read_timeout=$3; }
| TCP_MSG_READ_TIMEOUT EQUAL error { yyerror("number expected"); }
+ | TCP_MSG_DATA_TIMEOUT EQUAL NUMBER { ksr_tcp_msg_data_timeout=$3; }
+ | TCP_MSG_DATA_TIMEOUT EQUAL error { yyerror("number expected"); }
| TCP_CHECK_TIMER EQUAL NUMBER { ksr_tcp_check_timer=$3; }
| TCP_CHECK_TIMER EQUAL error { yyerror("number expected"); }
| CHILDREN EQUAL NUMBER { children_no=$3; }
diff --git a/src/core/globals.h b/src/core/globals.h
index aac82563d51..0d7227c9c1e 100644
--- a/src/core/globals.h
+++ b/src/core/globals.h
@@ -240,6 +240,7 @@ extern int ksr_rpc_exec_delta;
extern int ksr_msg_recv_max_size;
extern int ksr_tcp_msg_read_timeout;
+extern int ksr_tcp_msg_data_timeout;
extern int ksr_tcp_check_timer;
#ifdef USE_DNS_CACHE
diff --git a/src/core/tcp_init.h b/src/core/tcp_init.h
index 49c4ef7f748..f1c3ae61b37 100644
--- a/src/core/tcp_init.h
+++ b/src/core/tcp_init.h
@@ -40,7 +40,6 @@
#define DEFAULT_TCP_WBUF_SIZE 2100 /* after debugging switch to 4-16k */
-#define KSR_TCP_MSGREAD_TIMEOUT 20 /* timeout (secs) to read SIP message */
#define KSR_TCP_ACCEPT_IPLIMIT 1024 /* limit accepted tcp connections from IP */
struct tcp_child
diff --git a/src/core/tcp_main.c b/src/core/tcp_main.c
index bd8b162cd40..60f316d89b4 100644
--- a/src/core/tcp_main.c
+++ b/src/core/tcp_main.c
@@ -5518,7 +5518,7 @@ void tcp_timer_check_connections(unsigned int ticks, void *param)
if((cidset == 0)
&& !(con->req.dxstate & KSR_TCP_REQSTATE_DATARECV)) {
if(tvnow.tv_sec - con->timestamp
- >= ksr_tcp_msg_read_timeout) {
+ >= ksr_tcp_msg_data_timeout) {
LM_DBG("n: %d - connection id: %d (state: %d) - "
"message "
"receiving timeout: %ld\n",
diff --git a/src/main.c b/src/main.c
index a949d930407..3b678e14947 100644
--- a/src/main.c
+++ b/src/main.c
@@ -531,7 +531,8 @@ char *pid_file = 0; /* filename as asked by use */
char *pgid_file = 0;
int ksr_msg_recv_max_size = 32767; /* 2^15 - 1 */
-int ksr_tcp_msg_read_timeout = KSR_TCP_MSGREAD_TIMEOUT;
+int ksr_tcp_msg_read_timeout = 20; /* timeout (secs) to read SIP message */
+int ksr_tcp_msg_data_timeout = 20; /* timeout (secs) to receive first msg data */
int ksr_tcp_check_timer = 10; /* seconds to check tcp connections */
/* memory manager */