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

app_rpt: Acquire blocklock mutex when hard hanging up link channel. #460

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
10 changes: 7 additions & 3 deletions apps/app_rpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -4154,7 +4154,7 @@ static inline void free_frame(struct ast_frame **f)
}

/*! \brief Safely hang up any channel, even if a PBX could be running on it */
static inline void safe_hangup(struct ast_channel *chan)
static inline void safe_hangup(struct rpt *myrpt, struct ast_channel *chan)
{
/* myrpt is locked here, so we can trust this will be an atomic operation,
* since we also lock before setting the pbx to NULL */
Expand All @@ -4163,15 +4163,19 @@ static inline void safe_hangup(struct ast_channel *chan)
ast_softhangup(chan, AST_SOFTHANGUP_EXPLICIT);
} else {
ast_debug(3, "Hard hanging up channel %s\n", ast_channel_name(chan));
/* Another thread could be servicing the channel right now...
* so acquire the block lock to ensure we have exclusive control first. */
rpt_mutex_lock(&myrpt->blocklock);
ast_hangup(chan);
rpt_mutex_unlock(&myrpt->blocklock);
}
}

/*! \note myrpt->lock must be held when calling */
static inline void hangup_link_chan(struct rpt_link *l)
static inline void hangup_link_chan(struct rpt *myrpt, struct rpt_link *l)
{
if (l->chan) {
safe_hangup(l->chan);
safe_hangup(myrpt, l->chan);
l->chan = NULL;
}
}
Expand Down
Loading