Bladeren bron

dispatcher(k): use defines for probing modes

- it can be DS_PROBE_NONE (0), DS_PROBE_ALL (1) or DS_PROBE_INACTIVE (2)
- when ds_probing_mode is set to 2, keep probing inactive gateways until
  they become active. Note that the gateway must be set to probing when
  it goes in trying or inactive state
Daniel-Constantin Mierla 14 jaren geleden
bovenliggende
commit
d665458442
3 gewijzigde bestanden met toevoegingen van 20 en 6 verwijderingen
  1. 14 4
      modules_k/dispatcher/dispatch.c
  2. 4 0
      modules_k/dispatcher/dispatch.h
  3. 2 2
      modules_k/dispatcher/dispatcher.c

+ 14 - 4
modules_k/dispatcher/dispatch.c

@@ -2016,11 +2016,21 @@ int ds_update_state(sip_msg_t *msg, int group, str *address, int state)
 			/* reset the bits used for states */
 			idx->dlist[i].flags &= ~(DS_STATES_ALL);
 
+			if((state & DS_TRYING_DST) && (old_state & DS_INACTIVE_DST))
+			{
+				/* old state is inactive, new state is trying => keep it inactive
+				 * - it has to go first to active state and then to trying */
+				state &= ~ DS_TRYING_DST;
+				state |= ~ DS_INACTIVE_DST;
+			}
+
 			/* set the new states */
 			if(state & DS_DISABLED_DST)
+			{
 				idx->dlist[i].flags |= DS_DISABLED_DST;
-			else
+			} else {
 				idx->dlist[i].flags |= state;
+			}
 
 			if(state & DS_TRYING_DST)
 			{
@@ -2330,7 +2340,7 @@ static void ds_options_callback( struct cell *t, int type,
 
 		/* Set the according entry back to "Active" */
 		state = 0;
-		if (ds_probing_mode==1)
+		if (ds_probing_mode==DS_PROBE_ALL)
 			state |= DS_PROBING_DST;
 		if (ds_update_state(fmsg, group, &uri, state) != 0)
 		{
@@ -2339,7 +2349,7 @@ static void ds_options_callback( struct cell *t, int type,
 		}
 	} else {
 		state = DS_TRYING_DST;
-		if (ds_probing_mode==1)
+		if (ds_probing_mode!=DS_PROBE_NONE)
 			state |= DS_PROBING_DST;
 
 		if (faked_msg_init() < 0)
@@ -2388,7 +2398,7 @@ void ds_check_timer(unsigned int ticks, void* param)
 			if((list->dlist[j].flags&DS_DISABLED_DST) != 0)
 				continue;
 			/* If the Flag of the entry has "Probing set, send a probe:	*/
-			if (ds_probing_mode==1 ||
+			if (ds_probing_mode==DS_PROBE_ALL ||
 					(list->dlist[j].flags&DS_PROBING_DST) != 0)
 			{
 				LM_DBG("probing set #%d, URI %.*s\n", list->id,

+ 4 - 0
modules_k/dispatcher/dispatch.h

@@ -57,6 +57,10 @@
 
 #define ds_skip_dst(flags)	((flags) & (DS_INACTIVE_DST|DS_DISABLED_DST))
 
+#define DS_PROBE_NONE		0
+#define DS_PROBE_ALL		1
+#define DS_PROBE_INACTIVE	2
+
 extern str ds_db_url;
 extern str ds_table_name;
 extern str ds_set_id_col;

+ 2 - 2
modules_k/dispatcher/dispatcher.c

@@ -109,7 +109,7 @@ int probing_threshhold = 1; /* number of failed requests, before a destination
 str ds_ping_method = {"OPTIONS",7};
 str ds_ping_from   = {"sip:dispatcher@localhost", 24};
 static int ds_ping_interval = 0;
-int ds_probing_mode  = 0;
+int ds_probing_mode  = DS_PROBE_NONE;
 
 static str ds_ping_reply_codes_str= {NULL, 0};
 static int** ds_ping_reply_codes = NULL;
@@ -595,7 +595,7 @@ static int w_ds_mark_dst0(struct sip_msg *msg, char *str1, char *str2)
 	int state;
 
 	state = DS_INACTIVE_DST;
-	if (ds_probing_mode==1)
+	if (ds_probing_mode==DS_PROBE_ALL)
 		state |= DS_PROBING_DST;
 
 	return ds_mark_dst(msg, state);