diff --git a/debian/patches/series b/debian/patches/series index cdd7557bb..5b35dd8a0 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -31,3 +31,4 @@ sipwise/sca-fix-notify-after-bye.patch sipwise/fix_db_redis_time_schema.patch sipwise/fix_db_redis_free_memory.patch sipwise/fix_db_redis_memory_issues.patch +sipwise/rtpengine-balancing.patch diff --git a/debian/patches/sipwise/rtpengine-balancing.patch b/debian/patches/sipwise/rtpengine-balancing.patch new file mode 100644 index 000000000..1609ac0cd --- /dev/null +++ b/debian/patches/sipwise/rtpengine-balancing.patch @@ -0,0 +1,48 @@ +--- a/src/modules/rtpengine/rtpengine.c ++++ b/src/modules/rtpengine/rtpengine.c +@@ -2109,6 +2109,7 @@ + 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 ***/ + +@@ -2132,6 +2133,9 @@ + } + 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); +@@ -2282,7 +2286,26 @@ + 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 {