Skip to content

Commit

Permalink
dispatcher: add method to reinit state for all destinations in group
Browse files Browse the repository at this point in the history
  • Loading branch information
tverlaan committed Jan 14, 2018
1 parent 1f9366a commit d8cc862
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/modules/dispatcher/dispatch.c
Expand Up @@ -2605,6 +2605,39 @@ int ds_reinit_state(int group, str *address, int state)
return -1;
}

/**
*
*/
int ds_reinit_state_all(int group, int state)
{
int i = 0;
ds_set_t *idx = NULL;

if(_ds_list == NULL || _ds_list_nr <= 0) {
LM_ERR("the list is null\n");
return -1;
}

/* get the index of the set */
if(ds_get_index(group, *crt_idx, &idx) != 0) {
LM_ERR("destination set [%d] not found\n", group);
return -1;
}

for(i = 0; i < idx->nr; i++) {
int old_state = idx->dlist[i].flags;
/* reset the bits used for states */
idx->dlist[i].flags &= ~(DS_STATES_ALL);
/* set the new states */
idx->dlist[i].flags |= state;
if(idx->dlist[i].attrs.rweight > 0) {
ds_reinit_rweight_on_state_change(
old_state, idx->dlist[i].flags, idx);
}
}
return 0;
}

/**
*
*/
Expand Down
1 change: 1 addition & 0 deletions src/modules/dispatcher/dispatch.h
Expand Up @@ -115,6 +115,7 @@ int ds_select_dst(struct sip_msg *msg, int set, int alg, int mode);
int ds_next_dst(struct sip_msg *msg, int mode);
int ds_update_state(sip_msg_t *msg, int group, str *address, int state);
int ds_reinit_state(int group, str *address, int state);
int ds_reinit_state_all(int group, int state);
int ds_mark_dst(struct sip_msg *msg, int mode);
int ds_print_list(FILE *fout);
int ds_log_sets(void);
Expand Down

0 comments on commit d8cc862

Please sign in to comment.