Module: kamailio
Branch: master
Commit: 5077127b0fe1a2d803e42abe19cfcd93339f0519
URL:
https://github.com/kamailio/kamailio/commit/5077127b0fe1a2d803e42abe19cfcd9…
Author: Juha Heinanen <jh(a)tutpro.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-10-19T13:36:32+02:00
core: change tcp_check_timer initialization
- make tcp_check_timer default to depend on tcp_msg_data_timeout and
ksr_tcp_msg_read_timeout values, set to half of the minimum of the
two, it is not explicitely set
- GH #3608
---
Modified: src/main.c
---
Diff:
https://github.com/kamailio/kamailio/commit/5077127b0fe1a2d803e42abe19cfcd9…
Patch:
https://github.com/kamailio/kamailio/commit/5077127b0fe1a2d803e42abe19cfcd9…
---
diff --git a/src/main.c b/src/main.c
index 0fa2da6ec27..e299db3b319 100644
--- a/src/main.c
+++ b/src/main.c
@@ -535,7 +535,7 @@ 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_accept_iplimit = 1024; /* limit of accepted connections per IP */
-int ksr_tcp_check_timer = 10; /* seconds to check tcp connections */
+int ksr_tcp_check_timer = -1; /* seconds to check tcp connections */
/* memory manager */
#define SR_MEMMNG_DEFAULT "qm"
@@ -1726,12 +1726,25 @@ int main_loop(void)
cfg_main_reset_local();
#ifdef USE_TCP
- if(!tcp_disable && ksr_tcp_check_timer > 0) {
- if(sr_wtimer_add(
- tcp_timer_check_connections, NULL, ksr_tcp_check_timer)
- < 0) {
- LM_CRIT("cannot add timer for tcp connection checks\n");
- goto error;
+ if(!tcp_disable) {
+ if(ksr_tcp_check_timer == -1) {
+ if(ksr_tcp_msg_data_timeout > 0 && ksr_tcp_msg_read_timeout > 0)
+ ksr_tcp_check_timer = MIN(ksr_tcp_msg_data_timeout,
+ ksr_tcp_msg_read_timeout)
+ / 2;
+ else
+ ksr_tcp_check_timer =
+ ksr_tcp_msg_data_timeout > 0
+ ? ksr_tcp_msg_data_timeout / 2
+ : ksr_tcp_msg_read_timeout / 2;
+ }
+ if(ksr_tcp_check_timer > 0) {
+ if(sr_wtimer_add(tcp_timer_check_connections, NULL,
+ ksr_tcp_check_timer)
+ < 0) {
+ LM_CRIT("cannot add timer for tcp connection checks\n");
+ goto error;
+ }
}
}
#endif