mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Refactored the rest of the message types to use the STASIS_MESSAGE_TYPE_*
macros. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388751 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -565,10 +565,17 @@ struct ao2_container *stasis_cache_dump(struct stasis_caching_topic *caching_top
|
|||||||
*/
|
*/
|
||||||
#define STASIS_MESSAGE_TYPE_INIT(name) \
|
#define STASIS_MESSAGE_TYPE_INIT(name) \
|
||||||
({ \
|
({ \
|
||||||
|
ast_assert(_priv_ ## name == NULL); \
|
||||||
_priv_ ## name = stasis_message_type_create(#name); \
|
_priv_ ## name = stasis_message_type_create(#name); \
|
||||||
_priv_ ## name ? 0 : -1; \
|
_priv_ ## name ? 0 : -1; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Boiler-plate removing macro for cleaning up message types.
|
||||||
|
*
|
||||||
|
* \param name Name of message type.
|
||||||
|
* \since 12
|
||||||
|
*/
|
||||||
#define STASIS_MESSAGE_TYPE_CLEANUP(name) \
|
#define STASIS_MESSAGE_TYPE_CLEANUP(name) \
|
||||||
({ \
|
({ \
|
||||||
ao2_cleanup(_priv_ ## name); \
|
ao2_cleanup(_priv_ ## name); \
|
||||||
|
14
main/app.c
14
main/app.c
@@ -84,9 +84,10 @@ static AST_LIST_HEAD_STATIC(zombies, zombie);
|
|||||||
|
|
||||||
static struct stasis_topic *mwi_topic_all;
|
static struct stasis_topic *mwi_topic_all;
|
||||||
static struct stasis_caching_topic *mwi_topic_cached;
|
static struct stasis_caching_topic *mwi_topic_cached;
|
||||||
static struct stasis_message_type *mwi_state_type;
|
|
||||||
static struct stasis_topic_pool *mwi_topic_pool;
|
static struct stasis_topic_pool *mwi_topic_pool;
|
||||||
|
|
||||||
|
STASIS_MESSAGE_TYPE_DEFN(stasis_mwi_state_type);
|
||||||
|
|
||||||
static void *shaun_of_the_dead(void *data)
|
static void *shaun_of_the_dead(void *data)
|
||||||
{
|
{
|
||||||
struct zombie *cur;
|
struct zombie *cur;
|
||||||
@@ -2659,11 +2660,6 @@ struct stasis_caching_topic *stasis_mwi_topic_cached(void)
|
|||||||
return mwi_topic_cached;
|
return mwi_topic_cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stasis_message_type *stasis_mwi_state_type(void)
|
|
||||||
{
|
|
||||||
return mwi_state_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct stasis_topic *stasis_mwi_topic(const char *uniqueid)
|
struct stasis_topic *stasis_mwi_topic(const char *uniqueid)
|
||||||
{
|
{
|
||||||
return stasis_topic_pool_get_topic(mwi_topic_pool, uniqueid);
|
return stasis_topic_pool_get_topic(mwi_topic_pool, uniqueid);
|
||||||
@@ -2732,8 +2728,7 @@ static void app_exit(void)
|
|||||||
ao2_cleanup(mwi_topic_all);
|
ao2_cleanup(mwi_topic_all);
|
||||||
mwi_topic_all = NULL;
|
mwi_topic_all = NULL;
|
||||||
mwi_topic_cached = stasis_caching_unsubscribe(mwi_topic_cached);
|
mwi_topic_cached = stasis_caching_unsubscribe(mwi_topic_cached);
|
||||||
ao2_cleanup(mwi_state_type);
|
STASIS_MESSAGE_TYPE_CLEANUP(stasis_mwi_state_type);
|
||||||
mwi_state_type = NULL;
|
|
||||||
ao2_cleanup(mwi_topic_pool);
|
ao2_cleanup(mwi_topic_pool);
|
||||||
mwi_topic_pool = NULL;
|
mwi_topic_pool = NULL;
|
||||||
}
|
}
|
||||||
@@ -2748,8 +2743,7 @@ int app_init(void)
|
|||||||
if (!mwi_topic_cached) {
|
if (!mwi_topic_cached) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
mwi_state_type = stasis_message_type_create("stasis_mwi_state");
|
if (STASIS_MESSAGE_TYPE_INIT(stasis_mwi_state_type) != 0) {
|
||||||
if (!mwi_state_type) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
mwi_topic_pool = stasis_topic_pool_create(mwi_topic_all);
|
mwi_topic_pool = stasis_topic_pool_create(mwi_topic_all);
|
||||||
|
@@ -415,7 +415,7 @@ static struct {
|
|||||||
static struct stasis_topic *system_topic;
|
static struct stasis_topic *system_topic;
|
||||||
|
|
||||||
/*!\ brief The \ref stasis_message_type for network changes */
|
/*!\ brief The \ref stasis_message_type for network changes */
|
||||||
static struct stasis_message_type *network_change_type;
|
STASIS_MESSAGE_TYPE_DEFN(ast_network_change_type);
|
||||||
|
|
||||||
#if !defined(LOW_MEMORY)
|
#if !defined(LOW_MEMORY)
|
||||||
struct file_version {
|
struct file_version {
|
||||||
@@ -1063,18 +1063,12 @@ struct stasis_topic *ast_system_topic(void)
|
|||||||
return system_topic;
|
return system_topic;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stasis_message_type *ast_network_change_type(void)
|
|
||||||
{
|
|
||||||
return network_change_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! \brief Cleanup the \ref stasis system level items */
|
/*! \brief Cleanup the \ref stasis system level items */
|
||||||
static void stasis_system_topic_cleanup(void)
|
static void stasis_system_topic_cleanup(void)
|
||||||
{
|
{
|
||||||
ao2_ref(system_topic, -1);
|
ao2_ref(system_topic, -1);
|
||||||
system_topic = NULL;
|
system_topic = NULL;
|
||||||
ao2_ref(network_change_type, -1);
|
STASIS_MESSAGE_TYPE_CLEANUP(ast_network_change_type);
|
||||||
network_change_type = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Initialize the system level items for \ref stasis */
|
/*! \brief Initialize the system level items for \ref stasis */
|
||||||
@@ -1087,8 +1081,7 @@ static int stasis_system_topic_init(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
network_change_type = stasis_message_type_create("network_change");
|
if (STASIS_MESSAGE_TYPE_INIT(ast_network_change_type) != 0) {
|
||||||
if (!network_change_type) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -197,9 +197,10 @@ struct stasis_subscription *devstate_message_sub;
|
|||||||
|
|
||||||
static struct stasis_topic *device_state_topic_all;
|
static struct stasis_topic *device_state_topic_all;
|
||||||
static struct stasis_caching_topic *device_state_topic_cached;
|
static struct stasis_caching_topic *device_state_topic_cached;
|
||||||
static struct stasis_message_type *device_state_message_type;
|
|
||||||
static struct stasis_topic_pool *device_state_topic_pool;
|
static struct stasis_topic_pool *device_state_topic_pool;
|
||||||
|
|
||||||
|
STASIS_MESSAGE_TYPE_DEFN(ast_device_state_message_type);
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
static int getproviderstate(const char *provider, const char *address);
|
static int getproviderstate(const char *provider, const char *address);
|
||||||
|
|
||||||
@@ -723,11 +724,6 @@ struct stasis_caching_topic *ast_device_state_topic_cached(void)
|
|||||||
return device_state_topic_cached;
|
return device_state_topic_cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stasis_message_type *ast_device_state_message_type(void)
|
|
||||||
{
|
|
||||||
return device_state_message_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct stasis_topic *ast_device_state_topic(const char *device)
|
struct stasis_topic *ast_device_state_topic(const char *device)
|
||||||
{
|
{
|
||||||
return stasis_topic_pool_get_topic(device_state_topic_pool, device);
|
return stasis_topic_pool_get_topic(device_state_topic_pool, device);
|
||||||
@@ -781,8 +777,7 @@ static void devstate_exit(void)
|
|||||||
ao2_cleanup(device_state_topic_all);
|
ao2_cleanup(device_state_topic_all);
|
||||||
device_state_topic_all = NULL;
|
device_state_topic_all = NULL;
|
||||||
device_state_topic_cached = stasis_caching_unsubscribe(device_state_topic_cached);
|
device_state_topic_cached = stasis_caching_unsubscribe(device_state_topic_cached);
|
||||||
ao2_cleanup(device_state_message_type);
|
STASIS_MESSAGE_TYPE_CLEANUP(ast_device_state_message_type);
|
||||||
device_state_message_type = NULL;
|
|
||||||
ao2_cleanup(device_state_topic_pool);
|
ao2_cleanup(device_state_topic_pool);
|
||||||
device_state_topic_pool = NULL;
|
device_state_topic_pool = NULL;
|
||||||
}
|
}
|
||||||
@@ -797,8 +792,7 @@ int devstate_init(void)
|
|||||||
if (!device_state_topic_cached) {
|
if (!device_state_topic_cached) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
device_state_message_type = stasis_message_type_create("ast_device_state_message");
|
if (STASIS_MESSAGE_TYPE_INIT(ast_device_state_message_type) != 0) {
|
||||||
if (!device_state_message_type) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
device_state_topic_pool = stasis_topic_pool_create(ast_device_state_topic_all());
|
device_state_topic_pool = stasis_topic_pool_create(ast_device_state_topic_all());
|
||||||
|
@@ -360,7 +360,14 @@ struct ast_ha *ast_named_acl_find(const char *name, int *is_realtime, int *is_un
|
|||||||
static struct stasis_topic *acl_topic;
|
static struct stasis_topic *acl_topic;
|
||||||
|
|
||||||
/*! \brief Message type for named ACL changes */
|
/*! \brief Message type for named ACL changes */
|
||||||
static struct stasis_message_type *named_acl_change_type;
|
STASIS_MESSAGE_TYPE_DEFN(ast_named_acl_change_type);
|
||||||
|
|
||||||
|
static void acl_stasis_shutdown(void)
|
||||||
|
{
|
||||||
|
ao2_cleanup(acl_topic);
|
||||||
|
acl_topic = NULL;
|
||||||
|
STASIS_MESSAGE_TYPE_CLEANUP(ast_named_acl_change_type);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
@@ -368,8 +375,9 @@ static struct stasis_message_type *named_acl_change_type;
|
|||||||
*/
|
*/
|
||||||
static void ast_acl_stasis_init(void)
|
static void ast_acl_stasis_init(void)
|
||||||
{
|
{
|
||||||
|
ast_register_atexit(acl_stasis_shutdown);
|
||||||
acl_topic = stasis_topic_create("ast_acl");
|
acl_topic = stasis_topic_create("ast_acl");
|
||||||
named_acl_change_type = stasis_message_type_create("ast_named_acl_change");
|
STASIS_MESSAGE_TYPE_INIT(ast_named_acl_change_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stasis_topic *ast_acl_topic(void)
|
struct stasis_topic *ast_acl_topic(void)
|
||||||
@@ -377,11 +385,6 @@ struct stasis_topic *ast_acl_topic(void)
|
|||||||
return acl_topic;
|
return acl_topic;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stasis_message_type *ast_named_acl_change_type(void)
|
|
||||||
{
|
|
||||||
return named_acl_change_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
* \brief Sends a stasis message corresponding to a given named ACL that has changed or
|
* \brief Sends a stasis message corresponding to a given named ACL that has changed or
|
||||||
|
@@ -53,7 +53,7 @@ static const struct {
|
|||||||
{ "dnd", AST_PRESENCE_DND},
|
{ "dnd", AST_PRESENCE_DND},
|
||||||
};
|
};
|
||||||
|
|
||||||
struct stasis_message_type *presence_state_type;
|
STASIS_MESSAGE_TYPE_DEFN(ast_presence_state_message_type);
|
||||||
struct stasis_topic *presence_state_topic_all;
|
struct stasis_topic *presence_state_topic_all;
|
||||||
struct stasis_caching_topic *presence_state_topic_cached;
|
struct stasis_caching_topic *presence_state_topic_cached;
|
||||||
|
|
||||||
@@ -289,11 +289,6 @@ int ast_presence_state_changed(enum ast_presence_state state,
|
|||||||
return ast_presence_state_changed_literal(state, subtype, message, buf);
|
return ast_presence_state_changed_literal(state, subtype, message, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stasis_message_type *ast_presence_state_message_type(void)
|
|
||||||
{
|
|
||||||
return presence_state_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct stasis_topic *ast_presence_state_topic_all(void)
|
struct stasis_topic *ast_presence_state_topic_all(void)
|
||||||
{
|
{
|
||||||
return presence_state_topic_all;
|
return presence_state_topic_all;
|
||||||
@@ -321,14 +316,12 @@ static void presence_state_engine_cleanup(void)
|
|||||||
presence_state_topic_all = NULL;
|
presence_state_topic_all = NULL;
|
||||||
ao2_cleanup(presence_state_topic_cached);
|
ao2_cleanup(presence_state_topic_cached);
|
||||||
presence_state_topic_cached = NULL;
|
presence_state_topic_cached = NULL;
|
||||||
ao2_cleanup(presence_state_type);
|
STASIS_MESSAGE_TYPE_CLEANUP(ast_presence_state_message_type);
|
||||||
presence_state_type = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_presence_state_engine_init(void)
|
int ast_presence_state_engine_init(void)
|
||||||
{
|
{
|
||||||
presence_state_type = stasis_message_type_create("ast_presence_state_message");
|
if (STASIS_MESSAGE_TYPE_INIT(ast_presence_state_message_type) != 0) {
|
||||||
if (!presence_state_type) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
/*! Threadpool for dispatching notifications to subscribers */
|
/*! Threadpool for dispatching notifications to subscribers */
|
||||||
static struct ast_threadpool *pool;
|
static struct ast_threadpool *pool;
|
||||||
|
|
||||||
static struct stasis_message_type *__subscription_change_message_type;
|
STASIS_MESSAGE_TYPE_DEFN(stasis_subscription_change_type);
|
||||||
|
|
||||||
/*! \internal */
|
/*! \internal */
|
||||||
struct stasis_topic {
|
struct stasis_topic {
|
||||||
@@ -438,11 +438,6 @@ static struct stasis_subscription_change *subscription_change_alloc(struct stasi
|
|||||||
return change;
|
return change;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stasis_message_type *stasis_subscription_change_type(void)
|
|
||||||
{
|
|
||||||
return __subscription_change_message_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void send_subscription_change_message(struct stasis_topic *topic, char *uniqueid, char *description)
|
static void send_subscription_change_message(struct stasis_topic *topic, char *uniqueid, char *description)
|
||||||
{
|
{
|
||||||
RAII_VAR(struct stasis_subscription_change *, change, NULL, ao2_cleanup);
|
RAII_VAR(struct stasis_subscription_change *, change, NULL, ao2_cleanup);
|
||||||
@@ -556,10 +551,9 @@ struct stasis_topic *stasis_topic_pool_get_topic(struct stasis_topic_pool *pool,
|
|||||||
/*! \brief Cleanup function */
|
/*! \brief Cleanup function */
|
||||||
static void stasis_exit(void)
|
static void stasis_exit(void)
|
||||||
{
|
{
|
||||||
ao2_cleanup(__subscription_change_message_type);
|
|
||||||
__subscription_change_message_type = NULL;
|
|
||||||
ast_threadpool_shutdown(pool);
|
ast_threadpool_shutdown(pool);
|
||||||
pool = NULL;
|
pool = NULL;
|
||||||
|
STASIS_MESSAGE_TYPE_CLEANUP(stasis_subscription_change_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int stasis_init(void)
|
int stasis_init(void)
|
||||||
@@ -593,8 +587,7 @@ int stasis_init(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
__subscription_change_message_type = stasis_message_type_create("stasis_subscription_change");
|
if (STASIS_MESSAGE_TYPE_INIT(stasis_subscription_change_type) != 0) {
|
||||||
if (!__subscription_change_message_type) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -240,21 +240,8 @@ struct ao2_container *stasis_cache_dump(struct stasis_caching_topic *caching_top
|
|||||||
return cache_dump.cached;
|
return cache_dump.cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct stasis_message_type *cache_clear_type;
|
STASIS_MESSAGE_TYPE_DEFN(stasis_cache_clear_type);
|
||||||
|
STASIS_MESSAGE_TYPE_DEFN(stasis_cache_update_type);
|
||||||
struct stasis_message_type *stasis_cache_clear_type(void)
|
|
||||||
{
|
|
||||||
ast_assert(cache_clear_type != NULL);
|
|
||||||
return cache_clear_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct stasis_message_type *cache_update_type;
|
|
||||||
|
|
||||||
struct stasis_message_type *stasis_cache_update_type(void)
|
|
||||||
{
|
|
||||||
ast_assert(cache_update_type != NULL);
|
|
||||||
return cache_update_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cache_clear_dtor(void *obj)
|
static void cache_clear_dtor(void *obj)
|
||||||
{
|
{
|
||||||
@@ -442,30 +429,22 @@ struct stasis_caching_topic *stasis_caching_topic_create(struct stasis_topic *or
|
|||||||
|
|
||||||
static void stasis_cache_exit(void)
|
static void stasis_cache_exit(void)
|
||||||
{
|
{
|
||||||
ao2_cleanup(cache_clear_type);
|
STASIS_MESSAGE_TYPE_CLEANUP(stasis_cache_clear_type);
|
||||||
cache_clear_type = NULL;
|
STASIS_MESSAGE_TYPE_CLEANUP(stasis_cache_update_type);
|
||||||
ao2_cleanup(cache_update_type);
|
|
||||||
cache_update_type = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int stasis_cache_init(void)
|
int stasis_cache_init(void)
|
||||||
{
|
{
|
||||||
ast_register_atexit(stasis_cache_exit);
|
ast_register_atexit(stasis_cache_exit);
|
||||||
|
|
||||||
if (cache_clear_type || cache_update_type) {
|
if (STASIS_MESSAGE_TYPE_INIT(stasis_cache_clear_type) != 0) {
|
||||||
ast_log(LOG_ERROR, "Stasis cache double initialized\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_update_type = stasis_message_type_create("stasis_cache_update");
|
if (STASIS_MESSAGE_TYPE_INIT(stasis_cache_update_type) != 0) {
|
||||||
if (!cache_update_type) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_clear_type = stasis_message_type_create("StasisCacheClear");
|
|
||||||
if (!cache_clear_type) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,17 +35,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "asterisk/stasis.h"
|
#include "asterisk/stasis.h"
|
||||||
#include "asterisk/stasis_endpoints.h"
|
#include "asterisk/stasis_endpoints.h"
|
||||||
|
|
||||||
static struct stasis_message_type *endpoint_snapshot_type;
|
STASIS_MESSAGE_TYPE_DEFN(ast_endpoint_snapshot_type);
|
||||||
|
|
||||||
static struct stasis_topic *endpoint_topic_all;
|
static struct stasis_topic *endpoint_topic_all;
|
||||||
|
|
||||||
static struct stasis_caching_topic *endpoint_topic_all_cached;
|
static struct stasis_caching_topic *endpoint_topic_all_cached;
|
||||||
|
|
||||||
struct stasis_message_type *ast_endpoint_snapshot_type(void)
|
|
||||||
{
|
|
||||||
return endpoint_snapshot_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct stasis_topic *ast_endpoint_topic_all(void)
|
struct stasis_topic *ast_endpoint_topic_all(void)
|
||||||
{
|
{
|
||||||
return endpoint_topic_all;
|
return endpoint_topic_all;
|
||||||
@@ -176,12 +171,7 @@ int ast_endpoint_stasis_init(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!endpoint_snapshot_type) {
|
if (STASIS_MESSAGE_TYPE_INIT(ast_endpoint_snapshot_type) != 0) {
|
||||||
endpoint_snapshot_type = stasis_message_type_create(
|
|
||||||
"ast_endpoint_snapshot");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!endpoint_snapshot_type) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
main/test.c
18
main/test.c
@@ -57,7 +57,7 @@ struct stasis_topic *test_suite_topic;
|
|||||||
/*! \since 12
|
/*! \since 12
|
||||||
* \brief The message type for test suite messages
|
* \brief The message type for test suite messages
|
||||||
*/
|
*/
|
||||||
static struct stasis_message_type *test_suite_type;
|
STASIS_MESSAGE_TYPE_DEFN(ast_test_suite_message_type);
|
||||||
|
|
||||||
/*! This array corresponds to the values defined in the ast_test_state enum */
|
/*! This array corresponds to the values defined in the ast_test_state enum */
|
||||||
static const char * const test_result2str[] = {
|
static const char * const test_result2str[] = {
|
||||||
@@ -927,11 +927,6 @@ struct stasis_topic *ast_test_suite_topic(void)
|
|||||||
return test_suite_topic;
|
return test_suite_topic;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stasis_message_type *ast_test_suite_message_type(void)
|
|
||||||
{
|
|
||||||
return test_suite_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \since 12
|
* \since 12
|
||||||
* \brief A wrapper object that can be ao2 ref counted around an \ref ast_json blob
|
* \brief A wrapper object that can be ao2 ref counted around an \ref ast_json blob
|
||||||
@@ -1002,8 +997,7 @@ static void test_cleanup(void)
|
|||||||
{
|
{
|
||||||
ao2_cleanup(test_suite_topic);
|
ao2_cleanup(test_suite_topic);
|
||||||
test_suite_topic = NULL;
|
test_suite_topic = NULL;
|
||||||
ao2_cleanup(test_suite_type);
|
STASIS_MESSAGE_TYPE_CLEANUP(ast_test_suite_message_type);
|
||||||
test_suite_type = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1013,10 +1007,14 @@ int ast_test_init(void)
|
|||||||
#ifdef TEST_FRAMEWORK
|
#ifdef TEST_FRAMEWORK
|
||||||
/* Create stasis topic */
|
/* Create stasis topic */
|
||||||
test_suite_topic = stasis_topic_create("test_suite_topic");
|
test_suite_topic = stasis_topic_create("test_suite_topic");
|
||||||
test_suite_type = stasis_message_type_create("test_suite_type");
|
if (!test_suite_topic) {
|
||||||
if (!test_suite_topic || !test_suite_type) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (STASIS_MESSAGE_TYPE_INIT(ast_test_suite_message_type) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Register cli commands */
|
/* Register cli commands */
|
||||||
ast_cli_register_multiple(test_cli, ARRAY_LEN(test_cli));
|
ast_cli_register_multiple(test_cli, ARRAY_LEN(test_cli));
|
||||||
ast_register_atexit(test_cleanup);
|
ast_register_atexit(test_cleanup);
|
||||||
|
@@ -35,7 +35,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
|
|||||||
#include "asterisk/module.h"
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/stasis_test.h"
|
#include "asterisk/stasis_test.h"
|
||||||
|
|
||||||
static struct stasis_message_type *test_message_type;
|
STASIS_MESSAGE_TYPE_DEFN(stasis_test_message_type);
|
||||||
|
|
||||||
static void stasis_message_sink_dtor(void *obj)
|
static void stasis_message_sink_dtor(void *obj)
|
||||||
{
|
{
|
||||||
@@ -259,23 +259,15 @@ struct stasis_message *stasis_test_message_create(void)
|
|||||||
return stasis_message_create(stasis_test_message_type(), data);
|
return stasis_message_create(stasis_test_message_type(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stasis_message_type *stasis_test_message_type(void)
|
|
||||||
{
|
|
||||||
return test_message_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int unload_module(void)
|
static int unload_module(void)
|
||||||
{
|
{
|
||||||
ao2_cleanup(test_message_type);
|
STASIS_MESSAGE_TYPE_CLEANUP(stasis_test_message_type);
|
||||||
test_message_type = NULL;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int load_module(void)
|
static int load_module(void)
|
||||||
{
|
{
|
||||||
test_message_type = stasis_message_type_create(
|
if (STASIS_MESSAGE_TYPE_INIT(stasis_test_message_type) != 0) {
|
||||||
"stasis_test_message");
|
|
||||||
if (!test_message_type) {
|
|
||||||
return AST_MODULE_LOAD_FAILURE;
|
return AST_MODULE_LOAD_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user