Browse code

dispatcher: add some debug logging for ds_update_state function

(cherry picked from commit 8ee71161f907201e1734a4b2476636cfb518dab3)

Henning Westerholt authored on 14/10/2019 12:35:17
Showing 1 changed files
... ...
@@ -2688,6 +2688,7 @@ int ds_update_state(sip_msg_t *msg, int group, str *address, int state)
2688 2688
 		LM_ERR("destination set [%d] not found\n", group);
2689 2689
 		return -1;
2690 2690
 	}
2691
+	LM_DBG("update state for %.*s in group %d to %d\n", address->len, address->s, group, state);
2691 2692
 
2692 2693
 	while(i < idx->nr) {
2693 2694
 		if(idx->dlist[i].uri.len == address->len
... ...
@@ -2718,12 +2719,15 @@ int ds_update_state(sip_msg_t *msg, int group, str *address, int state)
2718 2719
 
2719 2720
 			if(state & DS_TRYING_DST) {
2720 2721
 				idx->dlist[i].message_count++;
2722
+				LM_DBG("destination did not replied %d times, threshold %d\n",
2723
+						 idx->dlist[i].message_count, probing_threshold);
2721 2724
 				/* Destination is not replying.. Increasing failure counter */
2722 2725
 				if(idx->dlist[i].message_count >= probing_threshold) {
2723
-					/* Destionation has too much lost messages.. Bringing it to inactive state */
2726
+					/* Destination has too much lost messages.. Bringing it to inactive state */
2724 2727
 					idx->dlist[i].flags &= ~DS_TRYING_DST;
2725 2728
 					idx->dlist[i].flags |= DS_INACTIVE_DST;
2726 2729
 					idx->dlist[i].message_count = 0;
2730
+					LM_DBG("deactivate destination, threshold %d reached\n", probing_threshold);
2727 2731
 				}
2728 2732
 			} else {
2729 2733
 				if(!(init_state & DS_TRYING_DST)
... ...
@@ -2733,9 +2737,12 @@ int ds_update_state(sip_msg_t *msg, int group, str *address, int state)
2733 2737
 					if(idx->dlist[i].message_count < inactive_threshold) {
2734 2738
 						/* Destination has not enough successful replies.. Leaving it into inactive state */
2735 2739
 						idx->dlist[i].flags |= DS_INACTIVE_DST;
2740
+						LM_DBG("destination replied successful %d times, threshold %d\n",
2741
+								 idx->dlist[i].message_count, inactive_threshold);
2736 2742
 					} else {
2737 2743
 						/* Destination has enough replied messages.. Bringing it to active state */
2738 2744
 						idx->dlist[i].message_count = 0;
2745
+						LM_DBG("activate destination, threshold %d reached\n", inactive_threshold);
2739 2746
 					}
2740 2747
 				} else {
2741 2748
 					idx->dlist[i].message_count = 0;
... ...
@@ -2753,6 +2760,7 @@ int ds_update_state(sip_msg_t *msg, int group, str *address, int state)
2753 2760
 				ds_reinit_rweight_on_state_change(
2754 2761
 						old_state, idx->dlist[i].flags, idx);
2755 2762
 
2763
+			LM_DBG("old state was %d, set new state to %d\n", old_state, idx->dlist[i].flags);
2756 2764
 			return 0;
2757 2765
 		}
2758 2766
 		i++;