Explorar o código

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

Juha Heinanen %!s(int64=14) %!d(string=hai) anos
pai
achega
f8108aac14
Modificáronse 2 ficheiros con 10 adicións e 6 borrados
  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) {
     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);
 	shm_free(target);
-	return 0;
+	return 2;
     }
     }
 
 
     target->gw_index = gw_index;
     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);
     LM_DBG("could not find (disabled) rule with id <%u>\n", rule_id);
     shm_free(target);
     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,
     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,
 	tag_len, prefix_len, from_uri_len, stopper, enabled, flags, gw_cnt,
 	hostname_len, params_len, defunct_until, null_gw_ip_addr, priority,
 	hostname_len, params_len, defunct_until, null_gw_ip_addr, priority,
-	weight;
+	weight, tmp;
     struct in_addr ip_addr;
     struct in_addr ip_addr;
     uri_type scheme;
     uri_type scheme;
     uri_transport transport;
     uri_transport transport;
@@ -1413,8 +1413,12 @@ int reload_tables()
 			   "not 1-254\n", i);
 			   "not 1-254\n", i);
 		    goto err;
 		    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);
 		    LM_ERR("could not insert target to rule <%u>\n", rule_id);
 		    goto err;
 		    goto err;
 		}
 		}