Module: kamailio Branch: 5.3 Commit: d9d677cbc30b2f771a3742c3aa95fd736dc48765 URL: https://github.com/kamailio/kamailio/commit/d9d677cbc30b2f771a3742c3aa95fd73...
Author: Henning Westerholt hw@skalatan.de Committer: Henning Westerholt hw@skalatan.de Date: 2019-12-19T17:44:19+01:00
dispatcher: fix bugs in ds_inactive threshold and ds_probing_mode 2 (GH #2100)
- fix bugs in ds_inactive threshold and ds_probing_mode 2 (GH #2100) - ds_mode 2 should ping only gateways with mode inactive and probing - ds_inactive threshould should work also in ds_probing_mode 0 and 2 - move ping logic to a small helper function
(cherry picked from commit ee45c2a07292cc977a7a212cac18fd2156279588)
---
Modified: src/modules/dispatcher/dispatch.c
---
Diff: https://github.com/kamailio/kamailio/commit/d9d677cbc30b2f771a3742c3aa95fd73... Patch: https://github.com/kamailio/kamailio/commit/d9d677cbc30b2f771a3742c3aa95fd73...
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c index 18b713ce02..86b7ca1f1a 100644 --- a/src/modules/dispatcher/dispatch.c +++ b/src/modules/dispatcher/dispatch.c @@ -2737,6 +2737,10 @@ int ds_update_state(sip_msg_t *msg, int group, str *address, int state) if(idx->dlist[i].message_count < inactive_threshold) { /* Destination has not enough successful replies.. Leaving it into inactive state */ idx->dlist[i].flags |= DS_INACTIVE_DST; + /* if destination was in probing state, we stay there for now */ + if((old_state & DS_PROBING_DST) != 0) { + idx->dlist[i].flags |= DS_PROBING_DST; + } LM_DBG("destination replied successful %d times, threshold %d\n", idx->dlist[i].message_count, inactive_threshold); } else { @@ -3176,6 +3180,32 @@ static void ds_options_callback( return; }
+/* + * Small helper to decide to ping a gateway or not + */ +static inline int ds_ping_result_helper(ds_set_t *node, int j) +{ + /* probe all */ + if(ds_probing_mode == DS_PROBE_ALL) { + LM_DBG("probe all, mode DS_PROBE_ALL\n"); + return 1; + } + /* probe if probing is set, but not in mode DS_PROBE_INACTIVE */ + if (ds_probing_mode != DS_PROBE_INACTIVE + && (node->dlist[j].flags & DS_PROBING_DST) != 0) { + LM_DBG("probing set, but not mode DS_PROBE_INACTIVE\n"); + return 1; + } + /* probe for mode DS_PROBE_INACTIVE only for inactive and probing gw */ + if (ds_probing_mode == DS_PROBE_INACTIVE + && (node->dlist[j].flags & DS_PROBING_DST) != 0 + && (node->dlist[j].flags & DS_INACTIVE_DST) != 0) { + LM_DBG("probing and inactive set, mode DS_PROBE_INACTIVE\n"); + return 1; + } + return 0; +} + /** * */ @@ -3196,8 +3226,7 @@ void ds_ping_set(ds_set_t *node) if((node->dlist[j].flags & DS_DISABLED_DST) != 0) continue; /* If the Flag of the entry has "Probing set, send a probe: */ - if(ds_probing_mode == DS_PROBE_ALL - || (node->dlist[j].flags & DS_PROBING_DST) != 0) { + if(ds_ping_result_helper(node, j)) { LM_DBG("probing set #%d, URI %.*s\n", node->id, node->dlist[j].uri.len, node->dlist[j].uri.s);