MT#55283 scale delete-delay

Change-Id: I61478a8f9d08921dd086735b96f6594e22690d30
pull/1938/head
Richard Fuchs 8 months ago
parent 482166f0dc
commit 4eadfd2274

@ -4884,7 +4884,7 @@ static void __tags_unassociate(struct call_monologue *a, struct call_monologue *
* *
* Returns `true`, if we need to update Redis. * Returns `true`, if we need to update Redis.
*/ */
static bool monologue_delete_iter(struct call_monologue *a, int delete_delay) { static bool monologue_delete_iter(struct call_monologue *a, int64_t delete_delay_us) {
call_t *call = a->call; call_t *call = a->call;
if (!call) if (!call)
return 0; return 0;
@ -4892,11 +4892,11 @@ static bool monologue_delete_iter(struct call_monologue *a, int delete_delay) {
GList *associated = g_hash_table_get_values(a->associated_tags); GList *associated = g_hash_table_get_values(a->associated_tags);
bool update_redis = false; bool update_redis = false;
if (delete_delay > 0) { if (delete_delay_us > 0) {
ilog(LOG_INFO, "Scheduling deletion of call branch '" STR_FORMAT_M "' " ilog(LOG_INFO, "Scheduling deletion of call branch '" STR_FORMAT_M "' "
"(via-branch '" STR_FORMAT_M "') in %d seconds", "(via-branch '" STR_FORMAT_M "') in %" PRId64 " seconds",
STR_FMT_M(&a->tag), STR_FMT0_M(&a->viabranch), delete_delay); STR_FMT_M(&a->tag), STR_FMT0_M(&a->viabranch), delete_delay_us / 1000000L);
a->deleted_us = rtpe_now + delete_delay * 1000000LL; // XXX scale to micro a->deleted_us = rtpe_now + delete_delay_us;
if (!call->ml_deleted_us || call->ml_deleted_us > a->deleted_us) if (!call->ml_deleted_us || call->ml_deleted_us > a->deleted_us)
call->ml_deleted_us = a->deleted_us; call->ml_deleted_us = a->deleted_us;
} }
@ -4915,7 +4915,7 @@ static bool monologue_delete_iter(struct call_monologue *a, int delete_delay) {
__tags_unassociate(a, b); __tags_unassociate(a, b);
if (g_hash_table_size(b->associated_tags) == 0) if (g_hash_table_size(b->associated_tags) == 0)
monologue_delete_iter(b, delete_delay); /* schedule deletion of B */ monologue_delete_iter(b, delete_delay_us); /* schedule deletion of B */
} }
g_list_free(associated); g_list_free(associated);
@ -5257,7 +5257,7 @@ static void monologue_stop(struct call_monologue *ml, bool stop_media_subsribers
// call must be locked in W. // call must be locked in W.
// unlocks the call and releases the reference prior to returning, even on error. // unlocks the call and releases the reference prior to returning, even on error.
int call_delete_branch(call_t *c, const str *branch, int call_delete_branch(call_t *c, const str *branch,
const str *fromtag, const str *totag, ng_command_ctx_t *ctx, int delete_delay) const str *fromtag, const str *totag, ng_command_ctx_t *ctx, int64_t delete_delay)
{ {
struct call_monologue *ml; struct call_monologue *ml;
int ret; int ret;
@ -5265,7 +5265,9 @@ int call_delete_branch(call_t *c, const str *branch,
bool update = false; bool update = false;
if (delete_delay < 0) if (delete_delay < 0)
delete_delay = rtpe_config.delete_delay; delete_delay = rtpe_config.delete_delay_us;
else
delete_delay *= 1000000L;
for (__auto_type i = c->monologues.head; i; i = i->next) { for (__auto_type i = c->monologues.head; i; i = i->next) {
ml = i->data; ml = i->data;
@ -5355,8 +5357,8 @@ del_all:
c->destroyed = rtpe_now; c->destroyed = rtpe_now;
if (delete_delay > 0) { if (delete_delay > 0) {
ilog(LOG_INFO, "Scheduling deletion of entire call in %d seconds", delete_delay); ilog(LOG_INFO, "Scheduling deletion of entire call in %" PRId64 " seconds", delete_delay / 1000000L);
c->deleted_us = rtpe_now + delete_delay * 1000000LL; // XXX scale to micro c->deleted_us = rtpe_now + delete_delay;
rwlock_unlock_w(&c->master_lock); rwlock_unlock_w(&c->master_lock);
} }
else { else {
@ -5388,7 +5390,7 @@ out:
int call_delete_branch_by_id(const str *callid, const str *branch, int call_delete_branch_by_id(const str *callid, const str *branch,
const str *fromtag, const str *totag, ng_command_ctx_t *ctx, int delete_delay) const str *fromtag, const str *totag, ng_command_ctx_t *ctx, int64_t delete_delay)
{ {
call_t *c = call_get(callid); call_t *c = call_get(callid);
if (!c) { if (!c) {

@ -1538,7 +1538,7 @@ static void cli_incoming_set_redisconnecttimeout(str *instr, struct cli_writer *
} }
static void cli_incoming_list_deletedelay(str *instr, struct cli_writer *cw, const cli_handler_t *handler) { static void cli_incoming_list_deletedelay(str *instr, struct cli_writer *cw, const cli_handler_t *handler) {
cw->cw_printf(cw, "%d\n", atomic_get_na(&rtpe_config.delete_delay)); cw->cw_printf(cw, "%" PRId64 "\n", atomic_get_na(&rtpe_config.delete_delay_us) / 1000000L);
} }
static void cli_incoming_set_deletedelay(str *instr, struct cli_writer *cw, const cli_handler_t *handler) { static void cli_incoming_set_deletedelay(str *instr, struct cli_writer *cw, const cli_handler_t *handler) {
@ -1552,7 +1552,7 @@ static void cli_incoming_set_deletedelay(str *instr, struct cli_writer *cw, cons
cw->cw_printf(cw, "Invalid delete-delay value\n"); cw->cw_printf(cw, "Invalid delete-delay value\n");
return; return;
} }
atomic_set_na(&rtpe_config.delete_delay, seconds); atomic_set_na(&rtpe_config.delete_delay_us, seconds * 1000000LL);
cw->cw_printf(cw, "Success setting delete-delay to %d\n", seconds); cw->cw_printf(cw, "Success setting delete-delay to %d\n", seconds);
} }

@ -86,7 +86,6 @@ struct rtpengine_config rtpe_config = {
// non-zero defaults // non-zero defaults
.kernel_table = -1, .kernel_table = -1,
.max_sessions = -1, .max_sessions = -1,
.delete_delay = 30,
.redis_subscribed_keyspaces = G_QUEUE_INIT, .redis_subscribed_keyspaces = G_QUEUE_INIT,
.redis_expires_secs = 86400, .redis_expires_secs = 86400,
.interfaces = TYPED_GQUEUE_INIT, .interfaces = TYPED_GQUEUE_INIT,
@ -676,6 +675,7 @@ static void options(int *argc, char ***argv, charp_ht templates) {
int timeout = 0; int timeout = 0;
int final_timeout = 0; int final_timeout = 0;
int offer_timeout = 0; int offer_timeout = 0;
int delete_delay = 30;
GOptionEntry e[] = { GOptionEntry e[] = {
{ "table", 't', 0, G_OPTION_ARG_INT, &rtpe_config.kernel_table, "Kernel table to use", "INT" }, { "table", 't', 0, G_OPTION_ARG_INT, &rtpe_config.kernel_table, "Kernel table to use", "INT" },
@ -749,7 +749,7 @@ static void options(int *argc, char ***argv, charp_ht templates) {
#ifdef WITH_TRANSCODING #ifdef WITH_TRANSCODING
{ "codec-num-threads", 0, 0, G_OPTION_ARG_INT, &rtpe_config.codec_num_threads, "Number of transcoding threads for asynchronous operation", "INT" }, { "codec-num-threads", 0, 0, G_OPTION_ARG_INT, &rtpe_config.codec_num_threads, "Number of transcoding threads for asynchronous operation", "INT" },
#endif #endif
{ "delete-delay", 'd', 0, G_OPTION_ARG_INT, &rtpe_config.delete_delay, "Delay for deleting a session from memory.", "INT" }, { "delete-delay", 'd', 0, G_OPTION_ARG_INT, &delete_delay, "Delay for deleting a session from memory.", "INT" },
{ "sip-source", 0, 0, G_OPTION_ARG_NONE, &sip_source, "Use SIP source address by default", NULL }, { "sip-source", 0, 0, G_OPTION_ARG_NONE, &sip_source, "Use SIP source address by default", NULL },
{ "dtls-passive", 0, 0, G_OPTION_ARG_NONE, &dtls_passive_def,"Always prefer DTLS passive role", NULL }, { "dtls-passive", 0, 0, G_OPTION_ARG_NONE, &dtls_passive_def,"Always prefer DTLS passive role", NULL },
{ "max-sessions", 0, 0, G_OPTION_ARG_INT, &rtpe_config.max_sessions, "Limit of maximum number of sessions", "INT" }, { "max-sessions", 0, 0, G_OPTION_ARG_INT, &rtpe_config.max_sessions, "Limit of maximum number of sessions", "INT" },
@ -1091,6 +1091,10 @@ static void options(int *argc, char ***argv, charp_ht templates) {
if (rtpe_config.final_timeout_us <= 0) if (rtpe_config.final_timeout_us <= 0)
rtpe_config.final_timeout_us = 0; rtpe_config.final_timeout_us = 0;
rtpe_config.delete_delay_us = delete_delay * 1000000LL;
if (rtpe_config.delete_delay_us < 0)
die("Invalid negative delete-delay");
if (rtpe_config.rtcp_interval <= 0) if (rtpe_config.rtcp_interval <= 0)
rtpe_config.rtcp_interval = 5000; rtpe_config.rtcp_interval = 5000;

@ -874,9 +874,9 @@ void dialogue_connect(struct call_monologue *, struct call_monologue *, sdp_ng_f
bool monologue_transform(struct call_monologue *, sdp_ng_flags *, medias_q *); bool monologue_transform(struct call_monologue *, sdp_ng_flags *, medias_q *);
void monologue_destroy(struct call_monologue *ml); void monologue_destroy(struct call_monologue *ml);
int call_delete_branch_by_id(const str *callid, const str *branch, int call_delete_branch_by_id(const str *callid, const str *branch,
const str *fromtag, const str *totag, ng_command_ctx_t *, int delete_delay); const str *fromtag, const str *totag, ng_command_ctx_t *, int64_t delete_delay);
int call_delete_branch(call_t *, const str *branch, int call_delete_branch(call_t *, const str *branch,
const str *fromtag, const str *totag, ng_command_ctx_t *, int delete_delay); const str *fromtag, const str *totag, ng_command_ctx_t *, int64_t delete_delay);
void call_destroy(call_t *); void call_destroy(call_t *);
struct call_media *call_media_new(call_t *call); struct call_media *call_media_new(call_t *call);
void call_media_free(struct call_media **mdp); void call_media_free(struct call_media **mdp);

@ -38,7 +38,6 @@ enum endpoint_learning {
X(max_sessions) \ X(max_sessions) \
X(moh_max_duration) \ X(moh_max_duration) \
X(moh_max_repeats) \ X(moh_max_repeats) \
X(delete_delay) \
X(redis_expires_secs) \ X(redis_expires_secs) \
X(default_tos) \ X(default_tos) \
X(control_tos) \ X(control_tos) \
@ -106,6 +105,7 @@ enum endpoint_learning {
X(timeout_us) \ X(timeout_us) \
X(final_timeout_us) \ X(final_timeout_us) \
X(offer_timeout_us) \ X(offer_timeout_us) \
X(delete_delay_us) \
#define RTPE_CONFIG_BOOL_PARAMS \ #define RTPE_CONFIG_BOOL_PARAMS \
X(homer_rtcp_off) \ X(homer_rtcp_off) \

Loading…
Cancel
Save