[sr-dev] git:3.1: modules/lcr: do not try to use rule target if its gw has been disabled.

Juha Heinanen jh at tutpro.com
Thu Dec 16 10:01:48 CET 2010


Module: sip-router
Branch: 3.1
Commit: 46eb7cc5e7ed341111f5cefd667b97f98d73591e
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=46eb7cc5e7ed341111f5cefd667b97f98d73591e

Author: Juha Heinanen <jh at tutpro.com>
Committer: Juha Heinanen <jh at 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.

---

 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 ff03714..b378565 100644
--- a/modules/lcr/lcr_mod.c
+++ b/modules/lcr/lcr_mod.c
@@ -894,7 +894,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;
@@ -1382,8 +1382,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;
 		}




More information about the sr-dev mailing list