From 06f4c6394222c95657757025d5fdcd5bb524ee4c Mon Sep 17 00:00:00 2001 From: lazedo Date: Wed, 13 Mar 2019 02:22:37 +0000 Subject: [PATCH] update keepalive --- kamailio/keepalive.cfg | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/kamailio/keepalive.cfg b/kamailio/keepalive.cfg index 159b3fb..76cac86 100644 --- a/kamailio/keepalive.cfg +++ b/kamailio/keepalive.cfg @@ -6,6 +6,8 @@ #!trydef KEEPALIVE_INTERVAL 30 #!trydef KEEPALIVE_TIMEOUT 5000 #!trydef KEEPALIVE_FAILED_THRESHOLD 2 +#!trydef KEEPALIVE_EXPIRE_SUBSCRIPTIONS 1 +#!trydef KEEPALIVE_EXPIRE_REGISTRATIONS 1 #!substdef "!KEEPALIVE_S_FROM_URI!sip:keepalive@MY_HOSTNAME!g" #!substdef "!KEEPALIVE_S_TIMERS!$def(KEEPALIVE_TIMERS)!g" @@ -13,6 +15,8 @@ kazoo.keepalive_udp_only = KEEPALIVE_UDP_ONLY descr "should we send keepalive for udp only" kazoo.keepalive_nat_only = KEEPALIVE_NAT_ONLY descr "should we send keepalive for nat phones only" kazoo.keepalive_timeout = KEEPALIVE_TIMEOUT descr "timeout in ms for keepalive transaction" +kazoo.keepalive_expire_subscriptions = KEEPALIVE_EXPIRE_SUBSCRIPTIONS descr "expires subscriptions that do not respond to OPTIONS" +kazoo.keepalive_expire_registrations = KEEPALIVE_EXPIRE_REGISTRATIONS descr "expires registrations that do not respond to OPTIONS" modparam("rtimer", "timer", "name=keepalive_timer;interval=1;mode=KEEPALIVE_S_TIMERS;") modparam("rtimer", "exec", "timer=keepalive_timer;route=KEEPALIVE_TIMER") @@ -48,10 +52,14 @@ route[KEEPALIVE_DB_TIMER] route[KEEPALIVE_CLEANUP] { lock("keepalive"); - $var(Query) = $_s(update location set expires = last_modified where id in(select a.id from location a inner join (select cast(substr(contact, 1, instr(contact,";")-1) as varchar(32)) contact from keepalive where slot = $rtimer_worker AND failed > $def(KEEPALIVE_FAILED_THRESHOLD)) b on substr(a.contact, 1, instr(a.contact,";")-1) = b.contact)); - sql_query("cb", "$var(Query)"); - $var(Query) = $_s(DELETE FROM active_watchers where id in(select a.id from keepalive a inner join active_watchers b on a.contact=b.contact where slot = $rtimer_worker and failed > $def(KEEPALIVE_FAILED_THRESHOLD))); - sql_query("cb", "$var(Query)"); + if($sel(cfg_get.kazoo.keepalive_expire_registrations) == 1) { + $var(Query) = $_s(update location set expires = last_modified where id in(select b.id from w_keepalive_contact a inner join w_location_contact b on a.contact = b.contact where slot = $rtimer_worker AND failed > $def(KEEPALIVE_FAILED_THRESHOLD))); + sql_query("cb", "$var(Query)"); + } + if($sel(cfg_get.kazoo.keepalive_expire_subscriptions) == 1) { + $var(Query) = $_s(DELETE FROM active_watchers where id in(select b.id from w_keepalive_contact a inner join w_watchers_contact b on a.contact = b.contact where slot = $rtimer_worker and failed > $def(KEEPALIVE_FAILED_THRESHOLD))); + sql_query("cb", "$var(Query)"); + } $var(Query) = $_s(DELETE FROM keepalive where slot = $rtimer_worker and failed > $def(KEEPALIVE_FAILED_THRESHOLD)); sql_query("cb", "$var(Query)"); unlock("keepalive");