فهرست منبع

modules/lcr: do not try to use rule target if its gw has been disabled.
(cherry picked from commit 46eb7cc5e7ed341111f5cefd667b97f98d73591e)

Juha Heinanen 14 سال پیش
والد
کامیت
f8108aac14
2فایلهای تغییر یافته به همراه10 افزوده شده و 6 حذف شده
  1. 3 3
      modules/lcr/hash.c
  2. 7 3
      modules/lcr/lcr_mod.c

+ 3 - 3
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;
 }
 
 

+ 7 - 3
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;
 		}