Skip to content

Commit

Permalink
core: change tcp_check_timer initialization
Browse files Browse the repository at this point in the history
 - 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
  • Loading branch information
juha-h authored and miconda committed Oct 19, 2023
1 parent 976da8c commit 5077127
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5077127

Please sign in to comment.