Skip to content

Commit

Permalink
dispatcher: turned ds_dns_mode values in bit flags
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Apr 5, 2022
1 parent cdf8cb6 commit bf6b1fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/modules/dispatcher/dispatch.c
Expand Up @@ -111,7 +111,7 @@ extern float ds_latency_estimator_alpha;
extern int ds_attrs_none;
extern param_t *ds_db_extra_attrs_list;
extern int ds_load_mode;
extern int ds_dns_mode;
extern uint32_t ds_dns_mode;

static db_func_t ds_dbf;
static db1_con_t *ds_db_handle = NULL;
Expand Down Expand Up @@ -486,7 +486,7 @@ ds_dest_t *pack_dest(str iuri, int flags, int priority, str *attrs, int dload)
/* Do a DNS-Lookup for the Host-Name, if not disabled via dst flags */
if(dp->flags & DS_NODNSARES_DST) {
dp->irmode |= DS_IRMODE_NOIPADDR;
} else if (ds_dns_mode==DS_DNS_MODE_INIT || ds_dns_mode==DS_DNS_MODE_TIMER) {
} else if (ds_dns_mode & (DS_DNS_MODE_INIT|DS_DNS_MODE_TIMER)) {
he = resolvehost(hn);
if(he == 0) {
LM_ERR("could not resolve %.*s (missing no-probing flag?!?)\n",
Expand Down
6 changes: 3 additions & 3 deletions src/modules/dispatcher/dispatch.h
Expand Up @@ -74,9 +74,9 @@

#define DS_IRMODE_NOIPADDR 1

#define DS_DNS_MODE_INIT 0
#define DS_DNS_MODE_ALWAYS 1
#define DS_DNS_MODE_TIMER 2
#define DS_DNS_MODE_INIT 1
#define DS_DNS_MODE_ALWAYS (1<<1)
#define DS_DNS_MODE_TIMER (1<<2)

/* clang-format on */
typedef struct ds_rctx {
Expand Down
11 changes: 4 additions & 7 deletions src/modules/dispatcher/dispatcher.c
Expand Up @@ -120,7 +120,8 @@ int ds_hash_check_interval = 30;
int ds_timer_mode = 0;
int ds_attrs_none = 0;
int ds_load_mode = 0;
int ds_dns_mode = 0;
uint32_t ds_dns_mode = DS_DNS_INIT;
static int ds_dns_mode_param = 0;

str ds_outbound_proxy = STR_NULL;

Expand Down Expand Up @@ -297,7 +298,7 @@ static param_export_t params[]={
{"ds_db_extra_attrs", PARAM_STR, &ds_db_extra_attrs},
{"ds_load_mode", PARAM_INT, &ds_load_mode},
{"reload_delta", PARAM_INT, &ds_reload_delta },
{"ds_dns_mode", PARAM_INT, &ds_dns_mode},
{"ds_dns_mode", PARAM_INT, &ds_dns_mode_param},
{0,0,0}
};

Expand Down Expand Up @@ -327,11 +328,7 @@ static int mod_init(void)
param_hooks_t phooks;
param_t *pit = NULL;

if(ds_dns_mode!=DS_DNS_MODE_INIT && ds_dns_mode!=DS_DNS_MODE_ALWAYS
&& ds_dns_mode!=DS_DNS_MODE_TIMER) {
LM_ERR("invalid dns mode %d\n", ds_dns_mode);
return -1;
}
ds_dns_mode = 1U<<(unsigned int)ds_dns_mode_param;

if(ds_ping_active_init() < 0) {
return -1;
Expand Down

0 comments on commit bf6b1fe

Please sign in to comment.