@ -40,12 +40,49 @@ route[DISPATCHER_FIND_ROUTES]
return;
}
if (!ds_select_dst("1", "0")) {
xlog("L_ERR", "$ci|end|no servers avaliable");
if (is_method("SUBSCRIBE")) {
$var(ds_group) = 20;
} else
if (is_method("REGISTER")) {
$var(ds_group) = 30;
} else {
$var(ds_group) = 1;
}
if (!ds_select_dst("$var(ds_group)", "0")) {
xlog("L_ERR", "$ci|end|no servers avaliable in group $var(ds_group)");
# if we selected from group 1, try again in group 2
if ($var(ds_group) = = 1 ) {
if (!ds_select_dst("2", "0")) {
xlog("L_ERR", "$ci|end|no servers avaliable in group 2");
sl_send_reply("480", "All servers busy");
exit;
}
} else {
sl_send_reply("480", "All servers busy");
exit;
sl_send_reply("480", "All servers busy");
}
} else {
# if we selected from group 1 and there are less than 3 available servers, choose from group 2
if ($var(ds_group) = = 1 && $var(ds_cnt)< 3) {
# clear $avp(ds_dst) and search in group 2
$(avp(ds_dst)[*]) = $null;
if (!ds_select_dst("2", "0")) {
xlog("L_ERR", "$ci|end|no servers avaliable in group 2");
sl_send_reply("480", "All servers busy");
exit;
}
}
exit;
}
$var(contact_uri) = $(ct{tobody.user}) + "@" + $(ct{tobody.host});