Module: sip-router Branch: master Commit: d665458442aed734bf1831e37ccf666ab2846f25 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d6654584...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Wed Nov 2 10:35:22 2011 +0100
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
---
modules_k/dispatcher/dispatch.c | 18 ++++++++++++++---- modules_k/dispatcher/dispatch.h | 4 ++++ modules_k/dispatcher/dispatcher.c | 4 ++-- 3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/modules_k/dispatcher/dispatch.c b/modules_k/dispatcher/dispatch.c index 768908c..11c3523 100644 --- a/modules_k/dispatcher/dispatch.c +++ b/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, diff --git a/modules_k/dispatcher/dispatch.h b/modules_k/dispatcher/dispatch.h index 5b051f0..ea44b27 100644 --- a/modules_k/dispatcher/dispatch.h +++ b/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; diff --git a/modules_k/dispatcher/dispatcher.c b/modules_k/dispatcher/dispatcher.c index edbbade..8206aec 100644 --- a/modules_k/dispatcher/dispatcher.c +++ b/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);