Skip to content

Commit

Permalink
app_rpt: Acquire blocklock mutex when hard hanging up link channel.
Browse files Browse the repository at this point in the history
Resolves: #459
  • Loading branch information
InterLinked1 committed Jan 20, 2025
1 parent e4dee90 commit 3457244
Showing 1 changed file with 7 additions and 3 deletions.
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

0 comments on commit 3457244

Please sign in to comment.