diff --git a/daemon/call.c b/daemon/call.c index 795c62f5d..8da4940b5 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -243,7 +243,7 @@ no_sfd: tmp_t_reason = SILENT_TIMEOUT; } else if (!PS_ISSET(ps, FILLED)) { - check = atomic_get_na(&rtpe_config.offer_timeout) * 1000000LL; // XXX scale to micro + check = atomic_get_na(&rtpe_config.offer_timeout_us); tmp_t_reason = OFFER_TIMEOUT; } diff --git a/daemon/cli.c b/daemon/cli.c index 6200aa754..a59a3be6b 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -660,7 +660,7 @@ static void cli_incoming_list_finaltimeout(str *instr, struct cli_writer *cw, co cw->cw_printf(cw, "FINAL_TIMEOUT=%" PRId64 "\n", rtpe_config.final_timeout_us / 1000000L); } static void cli_incoming_list_offertimeout(str *instr, struct cli_writer *cw, const cli_handler_t *handler) { - cw->cw_printf(cw, "OFFER_TIMEOUT=%u\n", rtpe_config.offer_timeout); + cw->cw_printf(cw, "OFFER_TIMEOUT=%" PRId64 "\n", rtpe_config.offer_timeout_us / 1000000L); } static void cli_incoming_list_callid(str *instr, struct cli_writer *cw) { @@ -1029,30 +1029,6 @@ static void cli_incoming_set_maxbw(str *instr, struct cli_writer *cw, const cli_ return; } -static void cli_incoming_set_gentimeout(str *instr, struct cli_writer *cw, int *conf_timeout) { - long timeout_num; - char *endptr; - - if (instr->len == 0) { - cw->cw_printf(cw, "More parameters required.\n"); - return; - } - - errno = 0; - timeout_num = strtol(instr->s, &endptr, 10); - - if ((errno == ERANGE && (timeout_num == ULONG_MAX)) || (errno != 0 && timeout_num == 0) || timeout_num < 0 || timeout_num >= INT_MAX) { - cw->cw_printf(cw, "Fail setting timeout to %s; errno=%d\n", instr->s, errno); - return; - } else if (endptr == instr->s) { - cw->cw_printf(cw, "Fail setting timeout to %s; no digits found\n", instr->s); - return; - } else { - atomic_set_na(conf_timeout, timeout_num); - cw->cw_printf(cw, "Success setting timeout to %lu\n", timeout_num); - } -} - static void cli_incoming_set_gentimeout_us(str *instr, struct cli_writer *cw, int64_t *conf_timeout) { long timeout_num; char *endptr; @@ -1087,7 +1063,7 @@ static void cli_incoming_set_finaltimeout(str *instr, struct cli_writer *cw, con cli_incoming_set_gentimeout_us(instr, cw, &rtpe_config.final_timeout_us); } static void cli_incoming_set_offertimeout(str *instr, struct cli_writer *cw, const cli_handler_t *handler) { - cli_incoming_set_gentimeout(instr, cw, &rtpe_config.offer_timeout); + cli_incoming_set_gentimeout_us(instr, cw, &rtpe_config.offer_timeout_us); } static void cli_generic_handler(str *instr, struct cli_writer *cw, const cli_handler_t *handler) { diff --git a/daemon/main.c b/daemon/main.c index e90d28b7f..d587375b0 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -675,6 +675,7 @@ static void options(int *argc, char ***argv, charp_ht templates) { int silent_timeout = 0; int timeout = 0; int final_timeout = 0; + int offer_timeout = 0; GOptionEntry e[] = { { "table", 't', 0, G_OPTION_ARG_INT, &rtpe_config.kernel_table, "Kernel table to use", "INT" }, @@ -708,7 +709,7 @@ static void options(int *argc, char ***argv, charp_ht templates) { { "timeout", 'o', 0, G_OPTION_ARG_INT, &timeout, "RTP timeout", "SECS" }, { "silent-timeout",'s',0,G_OPTION_ARG_INT, &silent_timeout, "RTP timeout for muted", "SECS" }, { "final-timeout",'a',0,G_OPTION_ARG_INT, &final_timeout, "Call timeout", "SECS" }, - { "offer-timeout",0,0, G_OPTION_ARG_INT, &rtpe_config.offer_timeout, "Timeout for incomplete one-sided calls", "SECS" }, + { "offer-timeout",0,0, G_OPTION_ARG_INT, &offer_timeout, "Timeout for incomplete one-sided calls", "SECS" }, { "port-min", 'm', 0, G_OPTION_ARG_INT, &rtpe_config.port_min, "Lowest port to use for RTP", "INT" }, { "port-max", 'M', 0, G_OPTION_ARG_INT, &rtpe_config.port_max, "Highest port to use for RTP", "INT" }, { "redis", 'r', 0, G_OPTION_ARG_STRING, &redisps, "Connect to Redis database", "[PW@]IP:PORT/INT" }, @@ -1082,8 +1083,9 @@ static void options(int *argc, char ***argv, charp_ht templates) { if (rtpe_config.silent_timeout_us <= 0) rtpe_config.silent_timeout_us = 3600 * 1000000LL; - if (rtpe_config.offer_timeout <= 0) - rtpe_config.offer_timeout = 3600; + rtpe_config.offer_timeout_us = offer_timeout * 1000000LL; + if (rtpe_config.offer_timeout_us <= 0) + rtpe_config.offer_timeout_us = 3600 * 1000000LL; rtpe_config.final_timeout_us = final_timeout * 1000000LL; if (rtpe_config.final_timeout_us <= 0) diff --git a/include/main.h b/include/main.h index 89e6d22b3..9fd247794 100644 --- a/include/main.h +++ b/include/main.h @@ -36,7 +36,6 @@ enum endpoint_learning { #define RTPE_CONFIG_INT_PARAMS \ X(kernel_table) \ X(max_sessions) \ - X(offer_timeout) \ X(moh_max_duration) \ X(moh_max_repeats) \ X(delete_delay) \ @@ -106,6 +105,7 @@ enum endpoint_learning { X(silent_timeout_us) \ X(timeout_us) \ X(final_timeout_us) \ + X(offer_timeout_us) \ #define RTPE_CONFIG_BOOL_PARAMS \ X(homer_rtcp_off) \