소스 검색

rtpengine: add queried_nodes_limit parameter

- queried_nodes_limit: configure the total number of nodes inside a set
  to be tried before giving up selecting a rtpengine.
lucian balanceanu 10 년 전
부모
커밋
dac57a30ee
2개의 변경된 파일35개의 추가작업 그리고 2개의 파일을 삭제
  1. 21 0
      modules/rtpengine/doc/rtpengine_admin.xml
  2. 14 2
      modules/rtpengine/rtpengine.c

+ 21 - 0
modules/rtpengine/doc/rtpengine_admin.xml

@@ -175,6 +175,27 @@ modparam("rtpengine", "rtpengine_disable_tout", 20)
 ...
 modparam("rtpengine", "rtpengine_tout_ms", 2000)
 ...
+</programlisting>
+		</example>
+	</section>
+	<section id="rtpengine.p.queried_nodes_limit">
+		<title><varname>queried_nodes_limit</varname> (integer)</title>
+		<para>
+		The total number of nodes inside a set (sets are configurable via rtpengine_sock function) to be queried 
+		before giving up establishing a session. This brings more flexibility in case checking all rtpengines
+		would take too long. Max limit is 50.
+		</para>
+		<para>
+		<emphasis>
+			By default all nodes in a set are tried before giving up communicating with the rtpengines.
+		</emphasis>
+		</para>
+		<example>
+		<title>Set <varname>queried_nodes_limit</varname> parameter</title>
+		<programlisting format="linespecific">
+...
+modparam("rtpengine", "queried_nodes_limit", 5)
+...
 </programlisting>
 		</example>
 	</section>

+ 14 - 2
modules/rtpengine/rtpengine.c

@@ -95,7 +95,7 @@ MODULE_VERSION
 
 
 #define DEFAULT_RTPP_SET_ID		0
-
+#define MAX_RTPP_TRIED_NODES    50
 #define MI_SET_NATPING_STATE		"nh_enable_ping"
 #define MI_DEFAULT_NATPING_STATE	1
 
@@ -185,6 +185,7 @@ static struct mi_root* mi_show_rtpproxies(struct mi_root* cmd_tree,
 static int rtpengine_disable_tout = 60;
 static int rtpengine_retr = 5;
 static int rtpengine_tout_ms = 1000;
+static int queried_nodes_limit = MAX_RTPP_TRIED_NODES;
 static pid_t mypid;
 static unsigned int myseqn = 0;
 static str extra_id_pv_param = {NULL, 0};
@@ -282,6 +283,7 @@ static param_export_t params[] = {
 	{"rtpengine_disable_tout",INT_PARAM, &rtpengine_disable_tout },
 	{"rtpengine_retr",        INT_PARAM, &rtpengine_retr         },
 	{"rtpengine_tout_ms",     INT_PARAM, &rtpengine_tout_ms      },
+	{"queried_nodes_limit",   INT_PARAM, &queried_nodes_limit    },
 	{"db_url",                PARAM_STR, &rtpp_db_url },
 	{"table_name",            PARAM_STR, &rtpp_table_name },
 	{"url_col",               PARAM_STR, &rtpp_url_col },
@@ -885,6 +887,11 @@ mod_init(void)
 	if (rtpp_strings)
 		pkg_free(rtpp_strings);
 
+	if ((queried_nodes_limit < 1) || (queried_nodes_limit > MAX_RTPP_TRIED_NODES)) {
+		LM_ERR("queried_nodes_limit must be a number in the range 1..50 \n");
+		return -1;
+	}
+
 	if (load_tm_api( &tmb ) < 0)
 	{
 		LM_DBG("could not load the TM-functions - answer-offer model"
@@ -1250,7 +1257,7 @@ static bencode_item_t *rtpp_function_call(bencode_buffer_t *bencbuf, struct sip_
 	struct ng_flags_parse ng_flags;
 	bencode_item_t *item, *resp;
 	str callid, from_tag, to_tag, body, viabranch, error;
-	int ret;
+	int ret, queried_nodes;
 	struct rtpp_node *node;
 	char *cp;
 
@@ -1365,7 +1372,12 @@ static bencode_item_t *rtpp_function_call(bencode_buffer_t *bencbuf, struct sip_
 	if(msg->id != current_msg_id)
 		active_rtpp_set = default_rtpp_set;
 
+	queried_nodes = 0;
 	do {
+		if (++queried_nodes > queried_nodes_limit) {
+			LM_ERR("queried nodes limit reached\n");
+			goto error;
+		}
 		node = select_rtpp_node(callid, 1);
 		if (!node) {
 			LM_ERR("no available proxies\n");