Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parcall: hangup for parallel call group #67

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions modules/parcall/parcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ static bool parcall_first(struct le *le, void *arg)
}


static bool pargroup_hangup(struct le *le, void *arg)
{
struct parcall *c = le->data;
struct pargroup *g0 = arg;

if (c->group != g0)
return false;

struct call *call = c->call;
(void)ua_hangup(call_get_ua(call), call, 0, NULL);

return false;
}


static bool parcall_hangup(struct le *le, void *arg)
{
struct parcall *c = le->data;
Expand Down Expand Up @@ -508,6 +523,39 @@ static int cmd_parcall(struct re_printf *pf, void *arg)
}


/**
* Hangup parallel call group with given name. All calls in the group are
* terminated
*
* @param pf Print handler
* @param arg Command arguments (carg)
* carg->prm holds: <name>
*
* @return 0 if success, otherwise errorcode
*/
static int cmd_parhangup(struct re_printf *pf, void *arg)
{
struct cmd_arg *carg = arg;
struct pargroup *g;
struct pl name;

const char *usage = "usage: /parhangup <name>\n";

if (!str_isset(carg->prm)) {
(void)re_hprintf(pf, usage);
return EINVAL;
}

pl_set_str(&name, carg->prm);
g = find_pargroup(pf, &name, "parhangup");
if (!g)
return EINVAL;

hash_apply(d.parcalls, pargroup_hangup, g);
return 0;
}


/**
* Debug output of parallel call groups and parallel calls
*
Expand Down Expand Up @@ -538,6 +586,7 @@ static const struct cmd cmdv[] = {
{"paradd", 0,CMD_PRM, "Add a call target to a group", cmd_paradd },
{"parcall", 0,CMD_PRM, "Initiate parallel call to given group",
cmd_parcall },
{"parhangup",0,CMD_PRM, "Hangup parallel call group", cmd_parhangup},
{"pardebug", 0, 0, "Print parallel call data", cmd_pardebug},
};

Expand Down
Loading