mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-20 11:43:52 +00:00
Fixed a consistency problem with channel snapshot and endpoint state.
When channels are added to an endpoint, the code originally posted a channel snapshot to the endoint's topic directly. Turns out, this is a bad idea. This causes the endpoint to see an inconsistent view of the channel, since it will later receive in-flight messages with old channel snapshots. This patch instead just publishes channel state immediately after setting up the forward to the endpoint's topic. This gives the endpoints a consistent view of the channel's state. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@390472 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1409,22 +1409,9 @@ struct stasis_topic *ast_channel_topic(struct ast_channel *chan)
|
|||||||
int ast_endpoint_add_channel(struct ast_endpoint *endpoint,
|
int ast_endpoint_add_channel(struct ast_endpoint *endpoint,
|
||||||
struct ast_channel *chan)
|
struct ast_channel *chan)
|
||||||
{
|
{
|
||||||
RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
|
|
||||||
RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
|
|
||||||
|
|
||||||
ast_assert(chan != NULL);
|
ast_assert(chan != NULL);
|
||||||
ast_assert(endpoint != NULL);
|
ast_assert(endpoint != NULL);
|
||||||
|
|
||||||
snapshot = ast_channel_snapshot_create(chan);
|
|
||||||
if (!snapshot) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg = stasis_message_create(ast_channel_snapshot_type(), snapshot);
|
|
||||||
if (!msg) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
chan->endpoint_forward =
|
chan->endpoint_forward =
|
||||||
stasis_forward_all(chan->topic, ast_endpoint_topic(endpoint));
|
stasis_forward_all(chan->topic, ast_endpoint_topic(endpoint));
|
||||||
|
|
||||||
@@ -1432,7 +1419,7 @@ int ast_endpoint_add_channel(struct ast_endpoint *endpoint,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
stasis_publish(ast_endpoint_topic(endpoint), msg);
|
ast_publish_channel_state(chan);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user