Ensure dummy channels get a stasis topic.
authorDavid M. Lee <dlee@digium.com>
Fri, 8 Mar 2013 16:25:58 +0000 (16:25 +0000)
committerDavid M. Lee <dlee@digium.com>
Fri, 8 Mar 2013 16:25:58 +0000 (16:25 +0000)
Fixes test failure introduced in r382685.

(issue ASTERISK-20887)
(issue ASTERISK-20959)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@382721 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/channel.c
main/channel_internal_api.c
main/stasis.c

index df0a67b..3289eda 100644 (file)
@@ -1283,6 +1283,8 @@ struct ast_channel *ast_dummy_channel_alloc(void)
        ast_channel_epfd_set(tmp, -1);
 #endif
 
+       ast_channel_internal_setup_topics(tmp);
+
        headp = ast_channel_varshead(tmp);
        AST_LIST_HEAD_INIT_NOLOCK(headp);
 
index 8cc2e6c..d646d84 100644 (file)
@@ -1391,8 +1391,14 @@ struct stasis_topic *ast_channel_topic(struct ast_channel *chan)
 
 void ast_channel_internal_setup_topics(struct ast_channel *chan)
 {
+       const char *topic_name = chan->uniqueid;
        ast_assert(chan->topic == NULL);
        ast_assert(chan->forwarder == NULL);
-       chan->topic = stasis_topic_create(chan->uniqueid);
+
+       if (ast_strlen_zero(topic_name)) {
+               topic_name = "<dummy-channel>";
+       }
+
+       chan->topic = stasis_topic_create(topic_name);
        chan->forwarder = stasis_forward_all(chan->topic, ast_channel_topic_all());
 }
index f94736b..d1f1153 100644 (file)
@@ -337,6 +337,10 @@ void stasis_forward_message(struct stasis_topic *topic, struct stasis_topic *pub
        struct stasis_subscription **subscribers = NULL;
        size_t num_subscribers, i;
 
+       ast_assert(topic != NULL);
+       ast_assert(publisher_topic != NULL);
+       ast_assert(message != NULL);
+
        /* Copy the subscribers, so we don't have to hold the mutex for long */
        {
                SCOPED_AO2LOCK(lock, topic);