[svn-commits] dlee: branch dlee/stasis-cache-split r394000 - in /team/dlee/stasis-cache-spl...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed Jul 10 14:08:40 CDT 2013
Author: dlee
Date: Wed Jul 10 14:08:38 2013
New Revision: 394000
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394000
Log:
all and all_cached topics
Modified:
team/dlee/stasis-cache-split/include/asterisk/bridging.h
team/dlee/stasis-cache-split/include/asterisk/stasis_bridging.h
team/dlee/stasis-cache-split/include/asterisk/stasis_cache_pattern.h
team/dlee/stasis-cache-split/include/asterisk/stasis_channels.h
team/dlee/stasis-cache-split/main/bridging.c
team/dlee/stasis-cache-split/main/stasis_bridging.c
team/dlee/stasis-cache-split/main/stasis_channels.c
team/dlee/stasis-cache-split/main/stasis_endpoints.c
Modified: team/dlee/stasis-cache-split/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/include/asterisk/bridging.h?view=diff&rev=394000&r1=393999&r2=394000
==============================================================================
--- team/dlee/stasis-cache-split/include/asterisk/bridging.h (original)
+++ team/dlee/stasis-cache-split/include/asterisk/bridging.h Wed Jul 10 14:08:38 2013
@@ -402,6 +402,8 @@
struct ast_bridge_technology *technology;
/*! Private information unique to the bridge technology */
void *tech_pvt;
+ /*! Per-bridge topics */
+ struct stasis_cache_one *topics;
/*! Call ID associated with the bridge */
struct ast_callid *callid;
/*! Linked list of channels participating in the bridge */
Modified: team/dlee/stasis-cache-split/include/asterisk/stasis_bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/include/asterisk/stasis_bridging.h?view=diff&rev=394000&r1=393999&r2=394000
==============================================================================
--- team/dlee/stasis-cache-split/include/asterisk/stasis_bridging.h (original)
+++ team/dlee/stasis-cache-split/include/asterisk/stasis_bridging.h Wed Jul 10 14:08:38 2013
@@ -392,6 +392,15 @@
const char *bridge_id);
/*!
+ * \internal
+ * \brief Initialize the topics for a single bridge.
+ * \return 0 on success.
+ * \return Non-zero on error.
+ */
+int bridge_topics_init(struct ast_bridge *bridge);
+
+/*!
+ * \internal
* \brief Initialize the stasis bridging topic and message types
* \retval 0 on success
* \retval -1 on failure
Modified: team/dlee/stasis-cache-split/include/asterisk/stasis_cache_pattern.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/include/asterisk/stasis_cache_pattern.h?view=diff&rev=394000&r1=393999&r2=394000
==============================================================================
--- team/dlee/stasis-cache-split/include/asterisk/stasis_cache_pattern.h (original)
+++ team/dlee/stasis-cache-split/include/asterisk/stasis_cache_pattern.h Wed Jul 10 14:08:38 2013
@@ -83,9 +83,11 @@
* \brief Create the 'one' side of the cache pattern.
*
* \param all All side which aggregates this topic.
+ * \param name Base name for the topics.
* \return One side instance
*/
-struct stasis_cache_one *stasis_cache_one_create(struct stasis_cache_all *all);
+struct stasis_cache_one *stasis_cache_one_create(struct stasis_cache_all *all,
+ const char *name);
/*!
* \brief Call to cancel forwarding of toward the cache aggregator.
Modified: team/dlee/stasis-cache-split/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/include/asterisk/stasis_channels.h?view=diff&rev=394000&r1=393999&r2=394000
==============================================================================
--- team/dlee/stasis-cache-split/include/asterisk/stasis_channels.h (original)
+++ team/dlee/stasis-cache-split/include/asterisk/stasis_channels.h Wed Jul 10 14:08:38 2013
@@ -53,7 +53,7 @@
AST_STRING_FIELD(caller_name); /*!< Caller ID Name */
AST_STRING_FIELD(caller_number); /*!< Caller ID Number */
AST_STRING_FIELD(caller_dnid); /*!< Dialed ID Number */
- AST_STRING_FIELD(caller_ani); /*< Caller ID ANI Number */
+ AST_STRING_FIELD(caller_ani); /*!< Caller ID ANI Number */
AST_STRING_FIELD(caller_rdnis); /*!< Caller ID RDNIS Number */
AST_STRING_FIELD(caller_subaddr); /*!< Caller subaddress */
AST_STRING_FIELD(dialed_subaddr); /*!< Dialed subaddress */
@@ -541,7 +541,9 @@
/*!
* \brief Initialize the stasis channel topic and message types
- */
-void ast_stasis_channels_init(void);
+ * \return 0 on success
+ * \return Non-zero on error
+ */
+int ast_stasis_channels_init(void);
#endif /* STASIS_CHANNELS_H_ */
Modified: team/dlee/stasis-cache-split/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/bridging.c?view=diff&rev=394000&r1=393999&r2=394000
==============================================================================
--- team/dlee/stasis-cache-split/main/bridging.c (original)
+++ team/dlee/stasis-cache-split/main/bridging.c Wed Jul 10 14:08:38 2013
@@ -1575,6 +1575,13 @@
ast_uuid_generate_str(self->uniqueid, sizeof(self->uniqueid));
ast_set_flag(&self->feature_flags, flags);
self->allowed_capabilities = capabilities;
+
+ if (bridge_topics_init(self) != 0) {
+ ast_log(LOG_WARNING, "Bridge %s: Could not initialize topics\n",
+ self->uniqueid);
+ ao2_ref(self, -1);
+ return NULL;
+ }
/* Use our helper function to find the "best" bridge technology. */
self->technology = find_best_technology(capabilities, self);
Modified: team/dlee/stasis-cache-split/main/stasis_bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/stasis_bridging.c?view=diff&rev=394000&r1=393999&r2=394000
==============================================================================
--- team/dlee/stasis-cache-split/main/stasis_bridging.c (original)
+++ team/dlee/stasis-cache-split/main/stasis_bridging.c Wed Jul 10 14:08:38 2013
@@ -33,6 +33,7 @@
#include "asterisk/astobj2.h"
#include "asterisk/stasis.h"
+#include "asterisk/stasis_cache_pattern.h"
#include "asterisk/channel.h"
#include "asterisk/stasis_bridging.h"
#include "asterisk/stasis_channels.h"
@@ -356,6 +357,8 @@
static struct ast_manager_event_blob *attended_transfer_to_ami(struct stasis_message *message);
static struct ast_manager_event_blob *blind_transfer_to_ami(struct stasis_message *message);
+static struct stasis_cache_all *bridge_cache_all;
+
/*!
* @{ \brief Define bridge message types.
*/
@@ -366,6 +369,35 @@
STASIS_MESSAGE_TYPE_DEFN(ast_blind_transfer_type, .to_ami = blind_transfer_to_ami);
STASIS_MESSAGE_TYPE_DEFN(ast_attended_transfer_type, .to_ami = attended_transfer_to_ami);
/*! @} */
+
+struct stasis_cache *ast_bridge_cache(void)
+{
+ return stasis_cache_all_cache(bridge_cache_all);
+}
+
+struct stasis_topic *ast_bridge_topic_all(void)
+{
+ return stasis_cache_all_topic(bridge_cache_all);
+}
+
+struct stasis_topic *ast_bridge_topic_all_cached(void)
+{
+ return stasis_cache_all_topic_cached(bridge_cache_all);
+}
+
+int bridge_topics_init(struct ast_bridge *bridge)
+{
+ if (ast_strlen_zero(bridge->uniqueid)) {
+ ast_log(LOG_ERROR, "Bridge id initialization required\n");
+ return -1;
+ }
+ bridge->topics = stasis_cache_one_create(bridge_cache_all,
+ bridge->uniqueid);
+ if (!bridge->topics) {
+ return -1;
+ }
+ return 0;
+}
/*! \brief Destructor for bridge snapshots */
static void bridge_snapshot_dtor(void *obj)
@@ -988,6 +1020,17 @@
return snapshot;
}
+/*! \brief snapshot ID getter for caching topic */
+static const char *bridge_snapshot_get_id(struct stasis_message *msg)
+{
+ struct ast_bridge_snapshot *snapshot;
+ if (stasis_message_type(msg) != ast_bridge_snapshot_type()) {
+ return NULL;
+ }
+ snapshot = stasis_message_data(msg);
+ return snapshot->uniqueid;
+}
+
static void stasis_bridging_cleanup(void)
{
STASIS_MESSAGE_TYPE_CLEANUP(ast_bridge_snapshot_type);
@@ -996,29 +1039,30 @@
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_left_bridge_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_blind_transfer_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_attended_transfer_type);
-}
-
-/*! \brief snapshot ID getter for caching topic */
-__attribute__((unused)) static const char *bridge_snapshot_get_id(struct stasis_message *msg)
-{
- struct ast_bridge_snapshot *snapshot;
- if (stasis_message_type(msg) != ast_bridge_snapshot_type()) {
- return NULL;
- }
- snapshot = stasis_message_data(msg);
- return snapshot->uniqueid;
+
+ ao2_cleanup(bridge_cache_all);
+ bridge_cache_all = NULL;
}
int ast_stasis_bridging_init(void)
{
+ int res = 0;
+
ast_register_cleanup(stasis_bridging_cleanup);
- STASIS_MESSAGE_TYPE_INIT(ast_bridge_snapshot_type);
- STASIS_MESSAGE_TYPE_INIT(ast_bridge_merge_message_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_entered_bridge_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_left_bridge_type);
- STASIS_MESSAGE_TYPE_INIT(ast_blind_transfer_type);
- STASIS_MESSAGE_TYPE_INIT(ast_attended_transfer_type);
-
- return 0;
-}
+ bridge_cache_all = stasis_cache_all_create("ast_bridge_topic_all",
+ bridge_snapshot_get_id);
+
+ if (!bridge_cache_all) {
+ return -1;
+ }
+
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_bridge_snapshot_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_bridge_merge_message_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_entered_bridge_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_left_bridge_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_blind_transfer_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_attended_transfer_type);
+
+ return res;
+}
Modified: team/dlee/stasis-cache-split/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/stasis_channels.c?view=diff&rev=394000&r1=393999&r2=394000
==============================================================================
--- team/dlee/stasis-cache-split/main/stasis_channels.c (original)
+++ team/dlee/stasis-cache-split/main/stasis_channels.c Wed Jul 10 14:08:38 2013
@@ -59,7 +59,30 @@
#define NUM_MULTI_CHANNEL_BLOB_BUCKETS 7
-__attribute__((unused)) static const char *channel_snapshot_get_id(struct stasis_message *message)
+static struct stasis_cache_all *channel_cache_all;
+static struct stasis_cache *channel_cache_by_name;
+
+struct stasis_cache *ast_channel_cache(void)
+{
+ return stasis_cache_all_cache(channel_cache_all);
+}
+
+struct stasis_topic *ast_channel_topic_all(void)
+{
+ return stasis_cache_all_topic(channel_cache_all);
+}
+
+struct stasis_topic *ast_channel_topic_all_cached(void)
+{
+ return stasis_cache_all_topic_cached(channel_cache_all);
+}
+
+struct stasis_cache *ast_channel_cache_by_name(void)
+{
+ return channel_cache_by_name;
+}
+
+static const char *channel_snapshot_get_id(struct stasis_message *message)
{
struct ast_channel_snapshot *snapshot;
if (ast_channel_snapshot_type() != stasis_message_type(message)) {
@@ -69,7 +92,7 @@
return snapshot->uniqueid;
}
-__attribute__((unused)) static const char *channel_snapshot_get_name(struct stasis_message *message)
+static const char *channel_snapshot_get_name(struct stasis_message *message)
{
struct ast_channel_snapshot *snapshot;
if (ast_channel_snapshot_type() != stasis_message_type(message)) {
@@ -825,27 +848,47 @@
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_moh_stop_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_monitor_start_type);
STASIS_MESSAGE_TYPE_CLEANUP(ast_channel_monitor_stop_type);
-}
-
-void ast_stasis_channels_init(void)
-{
+
+ ao2_cleanup(channel_cache_by_name);
+ channel_cache_by_name = NULL;
+ ao2_cleanup(channel_cache_all);
+ channel_cache_all = NULL;
+}
+
+int ast_stasis_channels_init(void)
+{
+ int res = 0;
ast_register_cleanup(stasis_channels_cleanup);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_snapshot_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_dial_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_varset_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_user_event_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_hangup_request_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_begin_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_end_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_hold_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_unhold_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_chanspy_start_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_chanspy_stop_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_fax_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_hangup_handler_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_moh_start_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_moh_stop_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_monitor_start_type);
- STASIS_MESSAGE_TYPE_INIT(ast_channel_monitor_stop_type);
-}
+ channel_cache_all = stasis_cache_all_create("ast_channel_topic_all",
+ channel_snapshot_get_id);
+ if (!channel_cache_all) {
+ return -1;
+ }
+
+ channel_cache_by_name = stasis_cache_create_secondary(
+ ast_channel_cache(), channel_snapshot_get_name);
+ if (!channel_cache_by_name) {
+ return -1;
+ }
+
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_snapshot_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_dial_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_varset_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_user_event_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_hangup_request_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_begin_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_dtmf_end_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_hold_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_unhold_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_chanspy_start_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_chanspy_stop_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_fax_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_hangup_handler_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_moh_start_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_moh_stop_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_monitor_start_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_channel_monitor_stop_type);
+
+ return res;
+}
Modified: team/dlee/stasis-cache-split/main/stasis_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/stasis_endpoints.c?view=diff&rev=394000&r1=393999&r2=394000
==============================================================================
--- team/dlee/stasis-cache-split/main/stasis_endpoints.c (original)
+++ team/dlee/stasis-cache-split/main/stasis_endpoints.c Wed Jul 10 14:08:38 2013
@@ -73,6 +73,23 @@
</managerEvent>
***/
+static struct stasis_cache_all *endpoint_cache_all;
+
+struct stasis_cache *ast_endpoint_cache(void)
+{
+ return stasis_cache_all_cache(endpoint_cache_all);
+}
+
+struct stasis_topic *ast_endpoint_topic_all(void)
+{
+ return stasis_cache_all_topic(endpoint_cache_all);
+}
+
+struct stasis_topic *ast_endpoint_topic_all_cached(void)
+{
+ return stasis_cache_all_topic_cached(endpoint_cache_all);
+}
+
static struct ast_manager_event_blob *peerstatus_to_ami(struct stasis_message *msg);
STASIS_MESSAGE_TYPE_DEFN(ast_endpoint_snapshot_type);
@@ -204,7 +221,7 @@
* \return \c NULL if the message_type of the message isn't a handled snapshot.
* \since 12
*/
-__attribute__((unused)) static const char *endpoint_snapshot_get_id(struct stasis_message *message)
+static const char *endpoint_snapshot_get_id(struct stasis_message *message)
{
struct ast_endpoint_snapshot *snapshot;
@@ -259,19 +276,26 @@
static void endpoints_stasis_shutdown(void)
{
+ STASIS_MESSAGE_TYPE_CLEANUP(ast_endpoint_snapshot_type);
+ STASIS_MESSAGE_TYPE_CLEANUP(ast_endpoint_state_type);
+
+ ao2_cleanup(endpoint_cache_all);
+ endpoint_cache_all = NULL;
}
int ast_endpoint_stasis_init(void)
{
+ int res = 0;
ast_register_atexit(endpoints_stasis_shutdown);
- if (STASIS_MESSAGE_TYPE_INIT(ast_endpoint_snapshot_type) != 0) {
+ endpoint_cache_all = stasis_cache_all_create("endpoint_topic_all",
+ endpoint_snapshot_get_id);
+ if (!endpoint_cache_all) {
return -1;
}
- if (STASIS_MESSAGE_TYPE_INIT(ast_endpoint_state_type) != 0) {
- return -1;
- }
-
- return 0;
-}
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_endpoint_snapshot_type);
+ res |= STASIS_MESSAGE_TYPE_INIT(ast_endpoint_state_type);
+
+ return res;
+}
More information about the svn-commits
mailing list