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 324e69f3d5
commit a624208b32
7 changed files with 69 additions and 51 deletions

View File

@@ -1400,6 +1400,15 @@ void ast_channel_internal_swap_snapshots(struct ast_channel *a, struct ast_chann
b->snapshot = snapshot;
}
void ast_channel_internal_swap_endpoints(struct ast_channel *a, struct ast_channel *b)
{
struct ast_endpoint *endpoint;
endpoint = a->endpoint;
a->endpoint = b->endpoint;
b->endpoint = endpoint;
}
void ast_channel_internal_set_fake_ids(struct ast_channel *chan, const char *uniqueid, const char *linkedid)
{
ast_copy_string(chan->uniqueid.unique_id, uniqueid, sizeof(chan->uniqueid.unique_id));
@@ -1598,3 +1607,22 @@ struct ast_flags *ast_channel_snapshot_segment_flags(struct ast_channel *chan)
{
return &chan->snapshot_segment_flags;
}
struct ast_endpoint *ast_channel_endpoint(const struct ast_channel *chan)
{
return chan->endpoint;
}
void ast_channel_endpoint_set(struct ast_channel *chan, struct ast_endpoint *endpoint)
{
if (chan->endpoint) {
ast_endpoint_remove_channel(chan->endpoint, chan);
ao2_ref(chan->endpoint, -1);
}
chan->endpoint = ao2_bump(endpoint);
if (chan->endpoint) {
ast_endpoint_add_channel(chan->endpoint, chan);
}
}