[sr-dev] git:master:ee45c2a0: dispatcher: fix bugs in ds_inactive threshold and ds_probing_mode 2 (GH #2100)

Henning Westerholt hw at skalatan.de
Thu Dec 19 17:36:37 CET 2019


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

Author: Henning Westerholt <hw at skalatan.de>
Committer: Henning Westerholt <hw at skalatan.de>
Date: 2019-12-19T17:32:14+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

---

Modified: src/modules/dispatcher/dispatch.c

---

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

---

diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index ab55f21990..d56f579b14 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -2767,6 +2767,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 {
@@ -3235,6 +3239,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;
+}
+
 /**
  *
  */
@@ -3255,8 +3285,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);
 




More information about the sr-dev mailing list