[sr-dev] git:master:9178da02: rtpengine: add support for explicit load balancing options

Richard Fuchs rfuchs at sipwise.com
Mon Mar 4 18:37:21 CET 2019


Module: kamailio
Branch: master
Commit: 9178da02494d3fbb689db331535a31b75b28b614
URL: https://github.com/kamailio/kamailio/commit/9178da02494d3fbb689db331535a31b75b28b614

Author: Richard Fuchs <rfuchs at sipwise.com>
Committer: Richard Fuchs <rfuchs at sipwise.com>
Date: 2019-03-04T12:07:30-05:00

rtpengine: add support for explicit load balancing options

---

Modified: src/modules/rtpengine/rtpengine.c

---

Diff:  https://github.com/kamailio/kamailio/commit/9178da02494d3fbb689db331535a31b75b28b614.diff
Patch: https://github.com/kamailio/kamailio/commit/9178da02494d3fbb689db331535a31b75b28b614.patch

---

diff --git a/src/modules/rtpengine/rtpengine.c b/src/modules/rtpengine/rtpengine.c
index f27503c6cc..23e06a88a4 100644
--- a/src/modules/rtpengine/rtpengine.c
+++ b/src/modules/rtpengine/rtpengine.c
@@ -2309,6 +2309,7 @@ static bencode_item_t *rtpp_function_call(bencode_buffer_t *bencbuf, struct sip_
 	pv_value_t pv_val;
 	char md5[MD5_LEN];
 	char branch_buf[MAX_BRANCH_PARAM_LEN];
+	bencode_item_t *result;
 
 	/*** get & init basic stuff needed ***/
 
@@ -2332,6 +2333,9 @@ static bencode_item_t *rtpp_function_call(bencode_buffer_t *bencbuf, struct sip_
 	}
 	ng_flags.dict = bencode_dictionary(bencbuf);
 
+	item = bencode_dictionary_add_list(ng_flags.dict, "supports");
+	bencode_list_add_string(item, "load limit");
+
 	body.s = NULL;
 	if (op == OP_OFFER || op == OP_ANSWER) {
 		ng_flags.flags = bencode_list(bencbuf);
@@ -2499,7 +2503,26 @@ static bencode_item_t *rtpp_function_call(bencode_buffer_t *bencbuf, struct sip_
 		goto error;
 	}
 
-	if (!bencode_dictionary_get_strcmp(resp, "result", "error")) {
+	result = bencode_dictionary_get_expect(resp, "result", BENCODE_STRING);
+	if (!result) {
+		LM_ERR("No 'result' dictionary entry in response from proxy %.*s",
+				node->rn_url.len, node->rn_url.s);
+		goto error;
+	}
+
+	if (!bencode_strcmp(result, "load limit")) {
+		item = bencode_dictionary_get_expect(resp, "message", BENCODE_STRING);
+		if (!item)
+			LM_INFO("proxy %.*s has reached its load limit - trying next one",
+					node->rn_url.len, node->rn_url.s);
+		else
+			LM_INFO("proxy %.*s has reached its load limit (%.*s) - trying next one",
+					node->rn_url.len, node->rn_url.s,
+					item->iov[1].iov_len, item->iov[1].iov_base);
+		goto select_node;
+	}
+
+	if (!bencode_strcmp(result, "error")) {
 		if (!bencode_dictionary_get_str(resp, "error-reason", &error)) {
 			LM_ERR("proxy return error but didn't give an error reason: %.*s\n", ret, cp);
 		} else {




More information about the sr-dev mailing list