Browse Source

HELP-40268 impose a maximum calls per presentity

* usefull for multiple dialog in notify but it also prevents the loaded
bodies from presentity to calculate final body (even on single, because
we need to check the state) to fill PKG memory
4.3
lazedo 7 years ago
committed by Luis Azedo
parent
commit
e708a00460
2 changed files with 28 additions and 18 deletions
  1. +1
    -1
      kamailio/db_queries_kazoo.cfg
  2. +27
    -17
      kamailio/presence-role.cfg

+ 1
- 1
kamailio/db_queries_kazoo.cfg View File

@ -2,7 +2,7 @@
#!substdef "!KZQ_CHECK_MEDIA_SERVER_INSERT!insert into dispatcher (setid, destination) select \$var(SetId), \"\$var(MediaUrl)\" where not exists(select * from dispatcher where destination = \"\$var(MediaUrl)\")!g"
#!substdef "!KZQ_COUNT_ALL_SUBSCRIBERS!select a.event, count(distinct watcher_username || \"@\" || watcher_domain) count_unique, count(*) count from event_list a, active_watchers b where b.event = a.event group by a.event!g"
#!substdef "!KZQ_COUNT_PRESENTITIES!select event, (select count(*) from presentity b where username = \"\$(var(payload){kz.json,From}{uri.user})\" and domain = \"\$(var(payload){kz.json,From}{uri.domain})\" and b.event = a.event) count from event_list a!g"
#!substdef "!KZQ_COUNT_SUBSCRIBERS!select event, (select count(*) from active_watchers b where presentity_uri = \"\$var(presentity)\" and b.event = a.event) count from event_list a!g"
#!substdef "!KZQ_COUNT_SUBSCRIBERS!select event, (select count(*) from active_watchers b where presentity_uri = \"\$var(presentity)\" and b.event = a.event) count from event_list a union select \"self\", count(*) from presentities where presentity_uri = \"\$var(presentity)\"!g"
#!substdef "!KZQ_EVENT_PRESENCE_RESET_DELETE!delete from presentity where domain=\"\$(kzE{kz.json,Realm})\" and username = \"\$(kzE{kz.json,Username})\"!g"
#!substdef "!KZQ_HANDLE_NEW_SUBSCRIBE_DELETE1!delete from active_watchers where callid = \"\$ci\"!g"
#!substdef "!KZQ_HANDLE_NEW_SUBSCRIBE_DELETE2!delete from active_watchers where watcher_username=\"\$fU\" and presentity_uri=\"\$var(presentity_uri)\" and to_user=\"\$tU\" and watcher_domain=\"\$fd\" and event=\"\$hdr(Event)\"!g"


+ 27
- 17
kamailio/presence-role.cfg View File

@ -4,6 +4,8 @@
#!trydef PRESENCE_MAX_EXPIRES 3600
#!trydef KZ_PRESENCE_IGNORE_STATUS_PROBE_RESP 1
#!trydef KZ_PRESENCE_MAX_CALL_PER_PRESENTITY 10
modparam("htable", "htable", "p=>size=32;autoexpire=3600;")
modparam("htable", "htable", "first=>size=32;autoexpire=3600;initval =0;updateexpire=1;")
@ -60,6 +62,7 @@ kazoo.presence_sync_amqp = KZ_PRESENCE_AMQP_PUBLISH descr "sync subscriptions to
kazoo.presence_request_probe = KZ_PRESENCE_REQUEST_PROBE descr "request probe for new subscriptions"
kazoo.presence_request_resubscribe_probe = KZ_PRESENCE_REQUEST_RESUBSCRIBE_PROBE descr "request probe for resubscriptions"
kazoo.presence_ignore_status_probe_resp = KZ_PRESENCE_IGNORE_STATUS_PROBE_RESP descr "ignore online/offline probe replies"
kazoo.presence_max_call_per_presentity = KZ_PRESENCE_MAX_CALL_PER_PRESENTITY descr "max number of calls per presentity"
#!ifdef FAST_PICKUP_ROLE
#!include_file "fast-pickup-role.cfg"
@ -400,23 +403,30 @@ route[PRESENCE_UPDATE]
route(COUNT_SUBSCRIBERS);
}
if($xavp(watchers=>dialog) > 0) {
if($(var(payload){kz.json,State}) == "terminated") {
xlog("L_DEBUG", "$(var(payload){kz.json,Call-ID})|log|publishing $var(presentity) dialog update for terminated dialog\n");
} else {
xlog("L_DEBUG", "$(var(payload){kz.json,Call-ID})|log|publishing $var(presentity) dialog update for $xavp(watchers=>dialog) watchers\n");
}
if(kazoo_pua_publish_dialoginfo($var(JObj)) == 1) {
pres_refresh_watchers("$var(presentity)", "dialog", 1);
} else {
xlog("L_ERR", "$(var(payload){kz.json,Call-ID})|log|error publishing $var(presentity) dialog update\n");
};
}
if($xavp(watchers=>presence) > 0) {
xlog("L_DEBUG", "$(var(payload){kz.json,Call-ID})|log|publishing $var(presentity) presence update for $xavp(watchers=>presence) watchers\n");
kazoo_pua_publish_presence($var(payload));
pres_refresh_watchers("$var(presentity)", "presence", 1);
if($xavp(watchers=>self) > $sel(cfg_get.kazoo.presence_max_call_per_presentity) &&
( $(var(payload){kz.json,State}) == "early" ||
($(var(payload){kz.json,State}) == "confirmed" && $(var(payload){kz.json,State}) == "initiator")
)) {
xlog("L_WARN", "$(var(payload){kz.json,Call-ID})|log|not publishing state $(var(payload){kz.json,State}) for presentity $var(presentity) with $xavp(watchers=>self) calls, policy limit of $sel(cfg_get.kazoo.presence_max_call_per_presentity) calls per presentity \n");
} else {
if($xavp(watchers=>dialog) > 0) {
if($(var(payload){kz.json,State}) == "terminated") {
xlog("L_DEBUG", "$(var(payload){kz.json,Call-ID})|log|publishing $var(presentity) dialog update for terminated dialog\n");
} else {
xlog("L_DEBUG", "$(var(payload){kz.json,Call-ID})|log|publishing $var(presentity) dialog update for $xavp(watchers=>dialog) watchers\n");
}
if(kazoo_pua_publish_dialoginfo($var(JObj)) == 1) {
pres_refresh_watchers("$var(presentity)", "dialog", 1);
} else {
xlog("L_ERR", "$(var(payload){kz.json,Call-ID})|log|error publishing $var(presentity) dialog update\n");
};
}
if($xavp(watchers=>presence) > 0) {
xlog("L_DEBUG", "$(var(payload){kz.json,Call-ID})|log|publishing $var(presentity) presence update for $xavp(watchers=>presence) watchers\n");
kazoo_pua_publish_presence($var(payload));
pres_refresh_watchers("$var(presentity)", "presence", 1);
}
}
}


Loading…
Cancel
Save