Skip to content

Commit

Permalink
dispatcher: first_hit_counter
Browse files Browse the repository at this point in the history
  • Loading branch information
ionel-cerghit committed Jul 3, 2015
1 parent c1dd6d2 commit 524bd1c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions modules/dispatcher/dispatch.c
Expand Up @@ -1368,6 +1368,7 @@ int ds_select_dst(struct sip_msg *msg, ds_select_ctl_p ds_select_ctl, ds_selecte
ds_dest_p dest = NULL;
ds_dest_p selected = NULL;
static ds_dest_p *sorted_set = NULL;
int rc;

if(msg==NULL) {
LM_ERR("bad parameters\n");
Expand Down Expand Up @@ -1589,14 +1590,20 @@ int ds_select_dst(struct sip_msg *msg, ds_select_ctl_p ds_select_ctl, ds_selecte

/* start pushing the destinations to SIP level */
cnt = 0;

rc = 1;
if(ds_select_ctl->set_destination
&& ds_update_dst(msg, &selected->dst_uri, selected->sock, ds_select_ctl->mode)!=0)
&& ((rc = ds_update_dst(msg, &selected->dst_uri, selected->sock, ds_select_ctl->mode)) != 0) )
{
LM_ERR("cannot set dst addr\n");
goto error;
}

if(rc == 0){
selected->chosen_count++;
LM_DBG("aici_intrat [%hu]\n", selected->chosen_count);
}


/* Save the selected destination for multilist failover */
if (selected_dst->uri.s != NULL) {
pkg_free(selected_dst->uri.s);
Expand Down Expand Up @@ -1745,7 +1752,7 @@ int ds_next_dst(struct sip_msg *msg, int mode, ds_partition_t *partition)
}

LM_DBG("using [%.*s]\n", avp_value.s.len, avp_value.s.s);
if(ds_update_dst(msg, &avp_value.s, sock, mode)!=0)
if( ds_update_dst(msg, &avp_value.s, sock, mode) != 0)
{
LM_ERR("cannot set dst addr\n");
return -1;
Expand Down Expand Up @@ -2057,6 +2064,11 @@ int ds_print_mi_list(struct mi_node* rpl, ds_partition_t *partition)
if(attr == NULL)
goto error;

p = int2str(list->dlist[j].chosen_count, &len);
attr = add_mi_attr (node, MI_DUP_VALUE, "first_hit_counter",17, p, len);
if(attr == NULL)
goto error;

if (list->dlist[j].sock)
{
p = socket2str(list->dlist[j].sock, NULL, &len, 0);
Expand Down
1 change: 1 addition & 0 deletions modules/dispatcher/dispatch.h
Expand Up @@ -86,6 +86,7 @@ typedef struct _ds_dest
unsigned short int ports[DS_MAX_IPS]; /* Port of the request URI */
unsigned short ips_cnt;
unsigned short failure_count;
unsigned short chosen_count;
void *param;
struct _ds_dest *next;
} ds_dest_t, *ds_dest_p;
Expand Down
1 change: 0 additions & 1 deletion modules/dispatcher/dispatcher.c
Expand Up @@ -171,7 +171,6 @@ static int w_ds_count(struct sip_msg*, char*, const char *, char*);

static int w_ds_is_in_list(struct sip_msg*, char*, char*, char*, char*);


static void destroy(void);

static struct mi_root* ds_mi_set(struct mi_root* cmd, void* param);
Expand Down

0 comments on commit 524bd1c

Please sign in to comment.