diff --git a/modules/dispatcher/dispatch.c b/modules/dispatcher/dispatch.c index 89f37dfa89d..4e16edbfc3a 100644 --- a/modules/dispatcher/dispatch.c +++ b/modules/dispatcher/dispatch.c @@ -67,6 +67,7 @@ #include "../../rw_locking.h" #include "dispatch.h" +#include "ds_fixups.h" #include "ds_bl.h" #define DS_TABLE_VERSION 7 @@ -2250,8 +2251,11 @@ void ds_check_timer(unsigned int ticks, void* param) { for(j=0; jnr; j++) { - /* If the Flag of the entry has "Probing set, send a probe: */ - if ( ((list->dlist[j].flags&DS_INACTIVE_DST)==0) && + /* If list is probed by this proxy and the Flag of + * the entry has "Probing" set, send a probe: + */ + if ( (!ds_probing_list || in_int_list(ds_probing_list, list->id)==0) && + ((list->dlist[j].flags&DS_INACTIVE_DST)==0) && (ds_probing_mode==1 || (list->dlist[j].flags&DS_PROBING_DST)!=0 )) { diff --git a/modules/dispatcher/dispatch.h b/modules/dispatcher/dispatch.h index c19459dd82f..243b8db0c46 100644 --- a/modules/dispatcher/dispatch.h +++ b/modules/dispatcher/dispatch.h @@ -194,7 +194,6 @@ extern int probing_threshhold; /* number of failed requests, before a destination is taken into probing */ extern int ds_probing_mode; - int init_ds_db(ds_partition_t *partition); int ds_connect_db(ds_partition_t *partition); void ds_disconnect_db(ds_partition_t *partition); diff --git a/modules/dispatcher/dispatcher.c b/modules/dispatcher/dispatcher.c index 9d38178ca84..4638b93cc01 100644 --- a/modules/dispatcher/dispatcher.c +++ b/modules/dispatcher/dispatcher.c @@ -83,6 +83,7 @@ str ds_ping_from = {"sip:dispatcher@localhost", 24}; static int ds_ping_interval = 0; int ds_probing_mode = 0; int ds_persistent_state = 1; +int_list_t *ds_probing_list = NULL; /* db partiton info */ @@ -183,6 +184,7 @@ static int mi_child_init(void); /* Parameters setters */ static int set_partition_arguments(unsigned int type, void * val); +static int set_probing_list(unsigned int type, void * val); static cmd_export_t cmds[]={ {"ds_select_dst", (cmd_function)w_ds_select_dst, 2, @@ -261,6 +263,7 @@ static param_export_t params[]={ {"ds_probing_mode", INT_PARAM, &ds_probing_mode}, {"options_reply_codes", STR_PARAM, &options_reply_codes_str.s}, {"ds_probing_sock", STR_PARAM, &probing_sock_s}, + {"ds_probing_list", STR_PARAM|USE_FUNC_PARAM, (void*)set_probing_list}, {"ds_define_blacklist", STR_PARAM|USE_FUNC_PARAM, (void*)set_ds_bl}, {"persistent_state", INT_PARAM, &ds_persistent_state}, {0,0,0} @@ -452,6 +455,17 @@ static ds_partition_t* find_partition_by_name (const str *partition_name) return part_it; //and NULL if there's no partition matching the name } +/* Load setids this proxy is responsible for probing into list */ +static int set_probing_list(unsigned int type, void *val) { + str input = {(char*)val, strlen(val)}; + if (set_list_from_string(input, &ds_probing_list) != 0 || + ds_probing_list == NULL) + { + LM_ERR("Invalid set_probing_list input\n"); + return -1; + } + return 0; +} /* We parse the "partition" argument as: partition_name:arg1=val1; arg2=val2;*/ @@ -920,6 +934,10 @@ static void destroy(void) /* destroy blacklists */ destroy_ds_bls(); + + /* destroy probing list */ + if (ds_probing_list) + free_int_list(ds_probing_list, NULL); } #define CHECK_AND_EXPAND_LIST(_list_) \ diff --git a/modules/dispatcher/doc/dispatcher_admin.xml b/modules/dispatcher/doc/dispatcher_admin.xml index 304c518ebf2..b93e75876a2 100644 --- a/modules/dispatcher/doc/dispatcher_admin.xml +++ b/modules/dispatcher/doc/dispatcher_admin.xml @@ -317,6 +317,30 @@ modparam("dispatcher", "ds_probing_mode", 1) +
+ <varname>ds_probing_list</varname> (str) + + Defines a list of one or more setids that limits which + destinations are probed if probing is active. This is useful + when multiple proxies share the same dispatcher table, but you + want to limit which ones are responsible for probing specific + destinations. + + + + Default value is NULL(none). + + + + Set the <quote>ds_probing_list</quote> parameter + +... +modparam("dispatcher", "ds_probing_list", "1,2,3") +... + + +
+
<varname>ds_define_blacklist</varname> (str) diff --git a/modules/dispatcher/ds_fixups.c b/modules/dispatcher/ds_fixups.c index 2a59c771149..57a4728e185 100644 --- a/modules/dispatcher/ds_fixups.c +++ b/modules/dispatcher/ds_fixups.c @@ -580,6 +580,20 @@ void free_int_list(int_list_t *start, int_list_t *end) } } +/* + * Search for value in int_list_t +*/ + +int in_int_list(int_list_t *list, int val) +{ + int_list_t *tmp; + for (tmp=list;tmp!=NULL;tmp=tmp->next) { + if (tmp->type == GPARAM_TYPE_INT && tmp->v.ival == val) + return 0; + } + return -1; +} + /* * Get a partition and a set from a general ds_param structure */ diff --git a/modules/dispatcher/ds_fixups.h b/modules/dispatcher/ds_fixups.h index b8684cfc488..95dba9d7175 100644 --- a/modules/dispatcher/ds_fixups.h +++ b/modules/dispatcher/ds_fixups.h @@ -79,8 +79,11 @@ typedef struct max_list_param { int type; } max_list_param_t, *max_list_param_p; +extern int_list_t *ds_probing_list; + int_list_t *set_list_from_pvs(struct sip_msg *msg, pv_spec_t *pvs, int_list_t *end); void free_int_list(int_list_t *start, int_list_t *end); +int in_int_list(int_list_t *list, int val); int fixup_get_partition(struct sip_msg *msg, const gpartition_t *gpart, ds_partition_t **partition);