Browse Source

Merge branch 'master' into 4.1

4.1 4.1.12
karl anderson 9 years ago
parent
commit
7260ce12ea
7 changed files with 55 additions and 30 deletions
  1. +8
    -0
      kamailio/defs.cfg
  2. +12
    -8
      kamailio/dispatcher-role.cfg
  3. +1
    -0
      kamailio/kazoodb.sql
  4. +32
    -11
      kamailio/presence-reset.cfg
  5. +1
    -3
      kamailio/presence-role.cfg
  6. +1
    -1
      kamailio/presence_notify_sync-role.cfg
  7. +0
    -7
      kamailio/registrar-sync-role.cfg

+ 8
- 0
kamailio/defs.cfg View File

@ -55,4 +55,12 @@
#!substdef "!MY_AMQP_ZONE!local!g"
#!endif
#!ifndef DISPATCHER_ADD_SERVERS
#!define DISPATCHER_ADD_SERVERS 1
#!endif
#!ifndef PRESENCE_RESET_BLF_DEFER_UPDATE
#!define PRESENCE_RESET_BLF_DEFER_UPDATE 0
#!endif
# vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab

+ 12
- 8
kamailio/dispatcher-role.cfg View File

@ -1,6 +1,8 @@
######## Generic Hash Table container in shared memory ########
modparam("htable", "htable", "failover=>size=16;autoexpire=120")
kazoo.dispatcher_auto_add = DISPATCHER_ADD_SERVERS descr "adds media servers reported by ecallmgr"
####### Dispatcher module ########
loadmodule "dispatcher.so"
modparam("dispatcher", "db_url", "KAZOO_DB_URL")
@ -214,14 +216,16 @@ event_route[dispatcher:dst-up]
route[DISPATCHER_CHECK_MEDIA_SERVER]
{
$var(SetId) = 1;
if($var(Zone) != "MY_AMQP_ZONE") {
$var(SetId) = 2;
}
sql_query("exec", "insert into dispatcher (setid, destination) select $var(SetId), \"$var(MediaUrl)\" where not exists(select * from dispatcher where destination = \"$var(MediaUrl)\")");
if($sqlrows(exec) > 0) {
xlog("L_WARNING", "reloading dispatcher table\n");
ds_reload();
if(@cfg_get.kazoo.dispatcher_auto_add == 1) {
$var(SetId) = 1;
if($var(Zone) != "MY_AMQP_ZONE") {
$var(SetId) = 2;
}
sql_query("exec", "insert into dispatcher (setid, destination) select $var(SetId), \"$var(MediaUrl)\" where not exists(select * from dispatcher where destination = \"$var(MediaUrl)\")");
if($sqlrows(exec) > 0) {
xlog("L_WARNING", "reloading dispatcher table\n");
ds_reload();
}
}
}


+ 1
- 0
kamailio/kazoodb.sql View File

@ -845,6 +845,7 @@ CREATE INDEX topos_t_rectime_idx ON topos_t (rectime);
CREATE INDEX topos_t_a_callid_idx ON topos_t (a_callid);
CREATE INDEX presentity_presentity_expires ON presentity (expires);
CREATE INDEX presentity_account_idx ON presentity (username, domain, event);
CREATE INDEX presentity_sender ON presentity (sender, username, domain, event);
CREATE INDEX active_watchers_active_watchers_expires ON active_watchers (expires);
CREATE INDEX active_watchers_active_watchers_pres ON active_watchers (presentity_uri, event);
CREATE INDEX active_watchers_updated_idx ON active_watchers (updated);


+ 32
- 11
kamailio/presence-reset.cfg View File

@ -1,5 +1,19 @@
kazoo.presence_reset_blf_defer_update = PRESENCE_RESET_BLF_DEFER_UPDATE descr "defers blf reset"
##### PRESENCE RESET ROUTINES
route[PRESENCE_RESET_ROUTE]
{
$var(runloop) = 1;
while(mq_fetch("blf_reset") == 1 && $var(runloop) < MAX_WHILE_LOOPS) {
$var(Key) = $mqk(blf_reset);
$sht(nodes=>$var(Key)) = 0;
$var(runloop) = $var(runloop) + 1;
}
}
route[PRESENCE_RESET_BINDINGS]
{
#!import_file "presence-reset-custom-bindings.cfg"
@ -13,8 +27,13 @@ route[PRESENCE_RESET_BINDINGS]
route[RESET_PUBLISHER]
{
xlog("L_INFO", "$var(Msg-ID)|reset|received presence reset for publisher $var(MediaUrl))\n");
sql_query("exec", "delete from presentity where sender = \"$var(MediaUrl)\"");
xlog("L_INFO", "$var(Msg-ID)|reset|received presence reset for publisher $var(MediaUrl))\n");
if(@cfg_get.kazoo.presence_reset_blf_defer_update == 0) {
$var(Query) = $_s(update active_watchers set expires = $TS where id in (select b.id from presentity a inner join active_watchers b on a.username = b.to_user and a.domain = b.to_domain and a.event = b.event where a.sender = "$var(MediaUrl)"));
sql_query("exec", "$var(Query)");
}
$var(Query) = $_s(delete from presentity where sender = "$var(MediaUrl)");
sql_query("exec", "$var(Query)");
$var(presentities) = $sqlrows(exec);
xlog("L_INFO", "$var(Msg-ID)|reset|removed $var(presentities) presentities from publisher $var(MediaUrl)\n");
}
@ -88,26 +107,28 @@ event_route[kazoo:consumer-event-presence-reset]
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|received presence reset for $(kzE{kz.json,Username})@$(kzE{kz.json,Realm})\n");
$var(presentity) = "sip:" + $(kzE{kz.json,Username}) + "@" + $(kzE{kz.json,Realm});
route(COUNT_SUBSCRIBERS);
sql_query("exec", 'delete from presentity where domain="$(kzE{kz.json,Realm})" and username = "$(kzE{kz.json,Username})"');
if(pres_has_subscribers("$var(presentity)", "message-summary")) {
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|notifying message-summary subscribers of $var(presentity)\n");
if($xavp(watchers=>message-summary) > 0) {
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|notifying $xavp(watchers=>message-summary) message-summary subscribers of $var(presentity)\n");
pres_refresh_watchers("$var(presentity)", "message-summary", 1);
} else {
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|skip message-summary subscriber notification for $var(presentity))\n");
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|skip message-summary subscriber notification for $var(presentity)\n");
}
if(pres_has_subscribers("$var(presentity)", "presence")) {
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|notifying presence subscribers of $var(presentity)\n");
if($xavp(watchers=>presence) > 0) {
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|notifying $xavp(watchers=>presence) presence subscribers of $var(presentity)\n");
pres_refresh_watchers("$var(presentity)", "presence", 1);
} else {
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|skip presence subscriber notification for $var(presentity))\n");
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|skip presence subscriber notification for $var(presentity)\n");
}
if(pres_has_subscribers("$var(presentity)", "dialog")) {
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|notifying dialog subscribers of $var(presentity)\n");
if($xavp(watchers=>dialog) > 0) {
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|notifying $xavp(watchers=>dialog) dialog subscribers of $var(presentity)\n");
pres_refresh_watchers("$var(presentity)", "dialog", 1);
} else {
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|skip dialog subscriber notification for $var(presentity))\n");
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|skip dialog subscriber notification for $var(presentity)\n");
}
}

+ 1
- 3
kamailio/presence-role.cfg View File

@ -64,9 +64,6 @@ modparam("nat_traversal", "keepalive_interval", 45)
#!include_file "presence_notify_sync-role.cfg"
#!endif
#!include_file "presence-reset.cfg"
####### Presence Logic ########
#!ifdef NAT_TRAVERSAL_ROLE
@ -274,6 +271,7 @@ event_route[kazoo:consumer-event-presence-update]
}
#!include_file "presence-reset.cfg"
route[PRESENCE_BINDINGS]
{


+ 1
- 1
kamailio/presence_notify_sync-role.cfg View File

@ -82,7 +82,7 @@ event_route[presence:notify-reply]
}
if(@cfg_get.kazoo.presence_notify_log_to_table == 1) {
$var(Query) = $_s(REPLACE INTO active_watchers_log (presentity_uri, watcher_username, watcher_domain, event, callid, to_user, to_domain, user_agent, time, result, sent_msg, received_msg) VALUES ("$subs(uri)", "$subs(watcher_username)", "$subs(watcher_domain)", "$subs(event)","$subs(callid)","$subs(to_user)","$subs(to_domain)", "$(subs(user_agent){s.escape.common}{s.replace,\','}{s.replace,$$,})", $TS, $notify_reply($rs), '$(mb{s.escape.common}{s.replace,\','}{s.replace,$$,})', '$(notify_reply($mb){s.escape.common}{s.replace,\','}{s.replace,$$,})'));
$var(Query) = $_s(REPLACE INTO active_watchers_log (presentity_uri, watcher_username, watcher_domain, event, callid, to_user, to_domain, user_agent, time, result, sent_msg, received_msg) VALUES ("$subs(uri)", "$subs(watcher_username)", "$subs(watcher_domain)", "$subs(event)","$subs(callid)","$subs(to_user)","$subs(to_domain)", '$(subs(user_agent){s.escape.common}{s.replace,\',''}{s.replace,$$,})', $TS, $notify_reply($rs), '$(mb{s.escape.common}{s.replace,\',''}{s.replace,$$,})', '$(notify_reply($mb){s.escape.common}{s.replace,\',''}{s.replace,$$,})'));
mq_add("presence_last_notity", "$subs(callid)", "$var(Query)");
}
}


+ 0
- 7
kamailio/registrar-sync-role.cfg View File

@ -1,12 +1,5 @@
######## Presence sync server module ########
####### SQL OPS module ##########
#!ifndef SQLOPS_LOADED
loadmodule "sqlops.so"
modparam("sqlops","sqlcon", "cb=>KAZOO_DB_URL")
#!trydef SQLOPS_LOADED
#!endif
event_route[kazoo:consumer-event-directory-reg-sync]
{
$var(Server) = $(kzE{kz.json,Server-ID});


Loading…
Cancel
Save