Skip to content

Commit

Permalink
dispatcher: $dsg(key) - count active/inactive targets in the group
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Sep 5, 2023
1 parent 873cd24 commit fef59a8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/modules/dispatcher/dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,7 @@ static int pv_get_dsg(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
int count = 0;
int active = 0;
int inactive = 0;
int j = 0;

if(param == NULL) {
return -1;
Expand All @@ -1405,6 +1406,17 @@ static int pv_get_dsg(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
return pv_get_null(msg, param, res);
}

lock_get(&dsg->lock);
count = dsg->nr;
for(j = 0; j < dsg->nr; j++) {
if(ds_skip_dst(dsg->dlist[j].flags)) {
inactive++;
} else {
active++;
}
}
lock_release(&dsg->lock);

switch(param->pvn.u.isname.name.n) {
case 0: /* count */
return pv_get_sintval(msg, param, res, count);
Expand Down

0 comments on commit fef59a8

Please sign in to comment.