Btw.: Attached is the patch for Kamailio 1.5, which i used back then... Carsten
2011/2/24 Klaus Feichtinger <klaus.li...@inode.at>: > Hello list, > > I have a question to the dispatcher module in Kamailio version 3.0.4. > > In my integration I use this module for distributing calls to a set of > gateways (with the round robin algorithm). Sometimes a gateway does not > react or send back a negative response. In that case I use the function > 'ds_mark_dst("p")' in the failure_route and mark the current destination > with the flag 'probing'. I have set the threshhold value for probing mode > to '10'. This means that a gateway is effectively set to probing mode only > when it was marked with the flag 'probing' for 10 times. However, > sometimes a gateway is sending back a negative response for e.g. 5 times > and is afterwards working fine - without any problems. A few hours later > (e.g.) it is sending a negative reply again for one time. This means: the > counter for the probing_flags is increasing every time when the function > ds_mark_dst("p") is executed (in case that the process was not restarted > in the meantime!). So the problem is, that the counter is reaching the > threshhold value at any time and at that moment the gateway is set to > probing mode. Even if the gateway has sent a negative reply for only one > time (at that moment) - but according the history the proging_flag was set > several times. > > What I miss in this module is a function to _reset_ that flag counter from > a REPLY_ROUTE. Note: I have to reset the counter, because the gateway does > not yet SIP OPTIONS requests and therefore it is set to 'probing' all time > until it is manually set back to active via MI command or after a process > restart. According the README file (and practical experience) the function > ds_mark_dst() is executable only within the failure_route. However, when I > want to set the flag ("a") for the current destination I will do it within > a reply_route, but not in the failure_route (because I have received a > positive response and not a negative one). From my point of view it does > not make sense setting the 'active' flag for a destination from within a > FAILURE route. > > Does anybody have an idea, how the 'flag-counter' could be reset (from > within the script)? I do not want to use a MI command..... > > configuration excerpt: > > [...] > modparam("dispatcher", "db_url", > "mysql://openser:openserrw@localhost/openser") > modparam("dispatcher", "table_name", "dispatcher") > modparam("dispatcher", "dst_avp", "$avp(AVP_DST)") > modparam("dispatcher", "grp_avp", "$avp(AVP_GRP)") > modparam("dispatcher", "cnt_avp", "$avp(AVP_CNT)") > modparam("dispatcher", "ds_ping_from", "sip:proxy@192.168.37.87") > modparam("dispatcher", "ds_probing_mode", 0) > modparam("dispatcher", "ds_probing_threshhold", 10) > modparam("dispatcher", "ds_ping_interval", 30) > modparam("dispatcher", "flags", 2) > modparam("dispatcher", "force_dst", 1) > [...] > if (!ds_select_dst("1", "4")) { > sl_send_reply("404", "No destination (disp)"); > exit; > } > t_on_failure("failureroute"); > t_on_reply("replyroute"); > [...] > failure_route[failureroute] { > [...] > if (t_check_status("[45][08]0") || (t_branch_timeout() && > !t_branch_replied())) { > ds_mark_dst("p"); > if (!ds_next_dst()) { > t_reply("404", "No destination (disp)"); > exit; > } > t_on_failure("failureroute"); > t_on_reply("replyroute"); > } > > [...] > } > onreply_route [replyroute] { > if (t_check_status("180|200") { > # nice to have...... > # ds_mark_dst("a"); > } > } > > Thanks in advance! > > regards, > Klaus > > > > _______________________________________________ > SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list > sr-users@lists.sip-router.org > http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users > -- Carsten Bock Schomburgstr. 80 22767 Hamburg Germany Mobile +49 179 2021244 Home +49 40 34927217 Büro (Verl) +49 5246 801427 Fax +49 40 34927218 mailto:cars...@bock.info
Index: modules/dispatcher/dispatch.c =================================================================== --- modules/dispatcher/dispatch.c (revision 5814) +++ modules/dispatcher/dispatch.c (working copy) @@ -1347,6 +1347,8 @@ ret = ds_set_state(group, &avp_value.s, DS_PROBING_DST, 1); if (ret == 0) ret = ds_set_state(group, &avp_value.s, DS_INACTIVE_DST, 0); + } else if(mode==3) { + ret = ds_set_state(group, &avp_value.s, DS_RESET_FAIL_DST, 1); } else { ret = ds_set_state(group, &avp_value.s, DS_INACTIVE_DST, 1); if (ret == 0) ret = ds_set_state(group, &avp_value.s, @@ -1408,12 +1410,12 @@ idx->dlist[i].failure_count = 0; state &= ~DS_RESET_FAIL_DST; } - - if(type) - idx->dlist[i].flags |= state; - else - idx->dlist[i].flags &= ~state; - + if (state) { + if(type) + idx->dlist[i].flags |= state; + else + idx->dlist[i].flags &= ~state; + } return 0; } i++; Index: modules/dispatcher/dispatcher.c =================================================================== --- modules/dispatcher/dispatcher.c (revision 5814) +++ modules/dispatcher/dispatcher.c (working copy) @@ -139,8 +139,8 @@ {"ds_select_domain", (cmd_function)w_ds_select_domain, 2, fixup_igp_igp, 0, REQUEST_ROUTE|FAILURE_ROUTE}, {"ds_next_dst", (cmd_function)w_ds_next_dst, 0, ds_warn_fixup, 0, FAILURE_ROUTE}, {"ds_next_domain", (cmd_function)w_ds_next_domain, 0, ds_warn_fixup, 0, FAILURE_ROUTE}, - {"ds_mark_dst", (cmd_function)w_ds_mark_dst0, 0, ds_warn_fixup, 0, FAILURE_ROUTE}, - {"ds_mark_dst", (cmd_function)w_ds_mark_dst1, 1, ds_warn_fixup, 0, FAILURE_ROUTE}, + {"ds_mark_dst", (cmd_function)w_ds_mark_dst0, 0, ds_warn_fixup, 0, FAILURE_ROUTE|ONREPLY_ROUTE}, + {"ds_mark_dst", (cmd_function)w_ds_mark_dst1, 1, ds_warn_fixup, 0, FAILURE_ROUTE|ONREPLY_ROUTE}, {"ds_is_from_list", (cmd_function)w_ds_is_from_list0, 0, 0, 0, REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE}, {"ds_is_from_list", (cmd_function)w_ds_is_from_list1, 1, fixup_uint_null, 0, REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE}, {0,0,0,0,0,0} @@ -461,6 +461,8 @@ return ds_mark_dst(msg, 0); else if(str1 && (str1[0]=='p' || str1[0]=='P' || str1[0]=='2')) return ds_mark_dst(msg, 2); + else if(str1 && (str1[0]=='r' || str1[0]=='R' || str1[0]=='3')) + return ds_mark_dst(msg, 3); else return ds_mark_dst(msg, 1); }
_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users