Module: sip-router
Branch: master
Commit: f8108aac14f5ce0696e88d8b8762f63ce96a22a4
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f8108aa…
Author: Juha Heinanen <jh(a)tutpro.com>
Committer: Juha Heinanen <jh(a)tutpro.com>
Date: Thu Dec 16 10:59:56 2010 +0200
modules/lcr: do not try to use rule target if its gw has been disabled.
(cherry picked from commit 46eb7cc5e7ed341111f5cefd667b97f98d73591e)
---
modules/lcr/hash.c | 6 +++---
modules/lcr/lcr_mod.c | 10 +++++++---
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/modules/lcr/hash.c b/modules/lcr/hash.c
index 4b55c89..4e24c94 100644
--- a/modules/lcr/hash.c
+++ b/modules/lcr/hash.c
@@ -118,9 +118,9 @@ int rule_hash_table_insert_target(struct rule_info **hash_table,
}
if (get_gw_index(gws, gw_id, &gw_index) == 0) {
- LM_ERR("could not find gw with id <%u>\n", gw_id);
+ LM_DBG("could not find (disabled) gw with id <%u>\n", gw_id);
shm_free(target);
- return 0;
+ return 2;
}
target->gw_index = gw_index;
@@ -141,7 +141,7 @@ int rule_hash_table_insert_target(struct rule_info **hash_table,
LM_DBG("could not find (disabled) rule with id <%u>\n", rule_id);
shm_free(target);
- return 1;
+ return 2;
}
diff --git a/modules/lcr/lcr_mod.c b/modules/lcr/lcr_mod.c
index 2ea532e..d64647a 100644
--- a/modules/lcr/lcr_mod.c
+++ b/modules/lcr/lcr_mod.c
@@ -906,7 +906,7 @@ int reload_tables()
unsigned int i, n, lcr_id, rule_id, gw_id, gw_name_len, port, strip,
tag_len, prefix_len, from_uri_len, stopper, enabled, flags, gw_cnt,
hostname_len, params_len, defunct_until, null_gw_ip_addr, priority,
- weight;
+ weight, tmp;
struct in_addr ip_addr;
uri_type scheme;
uri_transport transport;
@@ -1413,8 +1413,12 @@ int reload_tables()
"not 1-254\n", i);
goto err;
}
- if (!rule_hash_table_insert_target(rules, gws, rule_id, gw_id,
- priority, weight)) {
+ tmp = rule_hash_table_insert_target(rules, gws, rule_id, gw_id,
+ priority, weight);
+ if (tmp == 2) {
+ LM_INFO("skipping disabled <gw/rule> = <%u/%u>\n",
+ gw_id, rule_id);
+ } else if (tmp != 1) {
LM_ERR("could not insert target to rule <%u>\n", rule_id);
goto err;
}