endpoints: Remove need for stasis subscription.

When an endpoint is created in the core of Asterisk a subscription
was previously created alongside it to monitor any channels being
destroyed that were related to it. This was done by receiving all
channel snapshot updates for every channel and only reacting when
it was indicated that the channel was dead.

This change removes this logic and instead provides an API call
for directly removing a channel from an endpoint. This is called
when channels are destroyed. This operation is fast, so blocking
the calling thread for a short period of time doesn't have any
noticeable impact.
This commit is contained in:
Joshua C. Colp
2025-10-10 13:01:23 -03:00
committed by Asterisk Development Team
parent 3202f8c16d
commit 5b4aac6ba0
7 changed files with 69 additions and 51 deletions

View File

@@ -2847,6 +2847,16 @@ void ast_channel_internal_swap_endpoint_forward(struct ast_channel *a, struct as
*/
void ast_channel_internal_swap_snapshots(struct ast_channel *a, struct ast_channel *b);
/*!
* \brief Swap endpoints between two channels
* \param a First channel
* \param b Second channel
*
* \note
* This is used in masquerade to exchange endpoints
*/
void ast_channel_internal_swap_endpoints(struct ast_channel *a, struct ast_channel *b);
/*!
* \brief Set uniqueid and linkedid string value only (not time)
* \param chan The channel to set the uniqueid to
@@ -4262,6 +4272,8 @@ ast_callid ast_channel_callid(const struct ast_channel *chan);
struct ast_channel_snapshot *ast_channel_snapshot(const struct ast_channel *chan);
void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot);
struct ast_flags *ast_channel_snapshot_segment_flags(struct ast_channel *chan);
struct ast_endpoint *ast_channel_endpoint(const struct ast_channel *chan);
void ast_channel_endpoint_set(struct ast_channel *chan, struct ast_endpoint *endpoint);
/*!
* \pre chan is locked

View File

@@ -210,5 +210,18 @@ void ast_endpoint_set_max_channels(struct ast_endpoint *endpoint,
int ast_endpoint_add_channel(struct ast_endpoint *endpoint,
struct ast_channel *chan);
/*!
* \brief Removes a channel from the given endpoint.
* \since 23.1.0
* \since 22.7.0
* \since 20.17.0
*
* \param endpoint
* \param chan Channel.
* \retval 0 on success.
* \retval Non-zero on error.
*/
int ast_endpoint_remove_channel(struct ast_endpoint *endpoint,
struct ast_channel *chan);
#endif /* _ASTERISK_ENDPOINTS_H */