FreeCalypso > hg > themwi-system-sw
changeset 112:6aa63cf4620a
sip-in call clearing: select timeout implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 28 Sep 2022 18:59:55 -0800 |
parents | 7a4d4b8d5f04 |
children | bfc97065bf51 |
files | sip-in/call_list.c sip-in/main.c |
diffstat | 2 files changed, 29 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/sip-in/call_list.c Wed Sep 28 18:45:16 2022 -0800 +++ b/sip-in/call_list.c Wed Sep 28 18:59:55 2022 -0800 @@ -55,10 +55,12 @@ } void -scan_call_list_for_timeouts(retrans) - int *retrans; +scan_call_list_for_timeouts(retrans, dead_sip_flag, dead_sip_time) + int *retrans, *dead_sip_flag; + time_t *dead_sip_time; { struct call *call; + int got_dead_sip = 0; for (call = call_list; call; call = call->next) { switch (call->sip_state) { @@ -68,6 +70,18 @@ case SIP_STATE_BYE_SENT: *retrans = 1; break; + case SIP_STATE_ENDED: + case SIP_STATE_MSG_SIZE_ERR: + if (call->overall_state != OVERALL_STATE_DEAD_SIP) + continue; + if (got_dead_sip) { + if (call->sip_clear_time < *dead_sip_time) + *dead_sip_time = call->sip_clear_time; + } else { + got_dead_sip = 1; + *dead_sip_flag = 1; + *dead_sip_time = call->sip_clear_time; + } } } }
--- a/sip-in/main.c Wed Sep 28 18:45:16 2022 -0800 +++ b/sip-in/main.c Wed Sep 28 18:59:55 2022 -0800 @@ -33,8 +33,9 @@ char **argv; { fd_set fds; - int rc, need_retrans; + int rc, need_retrans, dead_sip_flag; struct timeval timeout; + time_t dead_sip_time; openlog("themwi-sip-in", 0, LOG_LOCAL5); read_config_file(); @@ -60,12 +61,21 @@ FD_SET(gsm_socket, &fds); if (mgw_is_connected) FD_SET(mgw_socket, &fds); - need_retrans = 0; - scan_call_list_for_timeouts(&need_retrans); + need_retrans = dead_sip_flag = 0; + scan_call_list_for_timeouts(&need_retrans, &dead_sip_flag, + &dead_sip_time); if (need_retrans) { timeout.tv_sec = cfg_retrans_timeout / 1000; timeout.tv_usec = (cfg_retrans_timeout % 1000) * 1000; rc = select(max_fd+1, &fds, 0, 0, &timeout); + } else if (dead_sip_flag) { + if (cur_event_time.tv_sec >= dead_sip_time) + timeout.tv_sec = 0; + else + timeout.tv_sec = + dead_sip_time - cur_event_time.tv_sec; + timeout.tv_usec = 0; + rc = select(max_fd+1, &fds, 0, 0, &timeout); } else rc = select(max_fd+1, &fds, 0, 0, 0); if (rc < 0) {