Browse code

- adding ds_probing_mode parameter to control which gateways are tested for availability (re-worked patch submitted by Konstantin Bokarius, #1893021)

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4308 689a6050-402a-0410-94f2-e92a70836424

Daniel-Constantin Mierla authored on 05/06/2008 07:12:44
Showing 4 changed files
... ...
@@ -1525,6 +1525,14 @@ static void ds_options_callback( struct cell *t, int type,
1525 1525
 					uri.s, group);
1526 1526
 		}
1527 1527
 	}
1528
+	if(ds_probing_mode==1 && ps->code == 407)
1529
+	{
1530
+		if (ds_set_state(group, &uri, DS_PROBING_DST, 1) != 0)
1531
+		{
1532
+			LM_ERR("Setting the probing state failed (%.*s, group %d)\n",
1533
+					uri.len, uri.s, group);
1534
+		}
1535
+	}
1528 1536
 
1529 1537
 	return;
1530 1538
 }
... ...
@@ -1559,7 +1567,8 @@ void ds_check_timer(unsigned int ticks, void* param)
1559 1567
 		for(j=0; j<list->nr; j++) 
1560 1568
 		{
1561 1569
 			/* If the Flag of the entry has "Probing set, send a probe:	*/
1562
-			if ((list->dlist[j].flags&DS_PROBING_DST) > 0)
1570
+			if (ds_probing_mode==1 ||
1571
+					(list->dlist[j].flags&DS_PROBING_DST) != 0)
1563 1572
 			{
1564 1573
 				LM_DBG("probing set #%d, URI %.*s\n", list->id,
1565 1574
 						list->dlist[j].uri.len, list->dlist[j].uri.s);
... ...
@@ -73,7 +73,9 @@ extern pv_spec_t ds_setid_pv;
73 73
 struct tm_binds tmb;
74 74
 extern str ds_ping_method;
75 75
 extern str ds_ping_from;
76
-extern int probing_threshhold; /* number of failed requests, before a destination is taken into probing */ 
76
+extern int probing_threshhold; /* number of failed requests,
77
+						before a destination is taken into probing */ 
78
+extern int ds_probing_mode;
77 79
 
78 80
 int init_data();
79 81
 int init_ds_db();
... ...
@@ -83,6 +83,7 @@ int probing_threshhold = 3; /* number of failed requests, before a destination
83 83
 str ds_ping_method = {"OPTIONS",7};
84 84
 str ds_ping_from   = {"sip:dispatcher@localhost", 24};
85 85
 static int ds_ping_interval = 0;
86
+int ds_probing_mode = 0;
86 87
 
87 88
 /*db */
88 89
 str ds_db_url         = {NULL, 0};
... ...
@@ -149,6 +150,7 @@ static param_export_t params[]={
149 150
 	{"ds_ping_method",     STR_PARAM, &ds_ping_method.s},
150 151
 	{"ds_ping_from",       STR_PARAM, &ds_ping_from.s},
151 152
 	{"ds_ping_interval",   INT_PARAM, &ds_ping_interval},
153
+	{"ds_probing_mode",    INT_PARAM, &ds_probing_mode},
152 154
 	{0,0,0}
153 155
 };
154 156
 
... ...
@@ -466,6 +466,29 @@ modparam("dispatcher", "force_dst", 1)
466 466
  		</example>
467 467
 	</section>
468 468
 
469
+ 	<section>
470
+ 		<title><varname>ds_probing_mode</varname> (int)</title>
471
+ 		<para>
472
+		Controls what gateways are tested to see if they are reachable. If set
473
+		to 0, only the gateways with state PROBING are tested, if set to 1, all
474
+		gateways are tested. If set to 1 and the response is 407 (timeout),
475
+		an active gateway is set to PROBING state.
476
+ 		</para>
477
+ 		<para>
478
+ 		<emphasis>
479
+ 			Default value is <quote>0</quote>.
480
+ 		</emphasis>
481
+ 		</para>
482
+ 		<example>
483
+ 		<title>Set the <quote>ds_probing_mode</quote> parameter</title>
484
+ <programlisting format="linespecific">
485
+ ...
486
+ modparam("dispatcher", "ds_probing_mode", 1)
487
+ ...
488
+ </programlisting>
489
+ 		</example>
490
+	</section>
491
+
469 492
 	</section>
470 493
 
471 494
 	<section>