[asterisk-commits] rmudgett: branch rmudgett/bridge_phase r385382 - in /team/rmudgett/bridge_pha...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Apr 11 16:57:50 CDT 2013
Author: rmudgett
Date: Thu Apr 11 16:57:47 2013
New Revision: 385382
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385382
Log:
Fix automerge conflict.
Added:
team/rmudgett/bridge_phase/include/asterisk/stasis_bridging.h
- copied unchanged from r385379, team/group/bridge_construction/include/asterisk/stasis_bridging.h
team/rmudgett/bridge_phase/main/manager_bridging.c
- copied unchanged from r385379, team/group/bridge_construction/main/manager_bridging.c
team/rmudgett/bridge_phase/main/stasis_bridging.c
- copied unchanged from r385379, team/group/bridge_construction/main/stasis_bridging.c
Modified:
team/rmudgett/bridge_phase/ (props changed)
team/rmudgett/bridge_phase/include/asterisk/manager.h
team/rmudgett/bridge_phase/include/asterisk/strings.h
team/rmudgett/bridge_phase/main/asterisk.c
team/rmudgett/bridge_phase/main/bridging.c
team/rmudgett/bridge_phase/main/manager.c
team/rmudgett/bridge_phase/main/manager_channels.c
team/rmudgett/bridge_phase/main/strings.c
Propchange: team/rmudgett/bridge_phase/
------------------------------------------------------------------------------
automerge = *
Propchange: team/rmudgett/bridge_phase/
------------------------------------------------------------------------------
--- branch-11-blocked (original)
+++ branch-11-blocked Thu Apr 11 16:57:47 2013
@@ -1,1 +1,1 @@
-/branches/11:373240,375247,375702
+/branches/11:373240,375247,375702,385356
Propchange: team/rmudgett/bridge_phase/
------------------------------------------------------------------------------
--- bridge_construction-integrated (original)
+++ bridge_construction-integrated Thu Apr 11 16:57:47 2013
@@ -1,1 +1,1 @@
-/trunk:1-385316
+/trunk:1-385357
Propchange: team/rmudgett/bridge_phase/
------------------------------------------------------------------------------
--- bridge_phase-integrated (original)
+++ bridge_phase-integrated Thu Apr 11 16:57:47 2013
@@ -1,1 +1,1 @@
-/team/group/bridge_construction:1-385329
+/team/group/bridge_construction:1-385380
Modified: team/rmudgett/bridge_phase/include/asterisk/manager.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/include/asterisk/manager.h?view=diff&rev=385382&r1=385381&r2=385382
==============================================================================
--- team/rmudgett/bridge_phase/include/asterisk/manager.h (original)
+++ team/rmudgett/bridge_phase/include/asterisk/manager.h Thu Apr 11 16:57:47 2013
@@ -316,6 +316,38 @@
*/
struct ast_datastore *astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid);
+/*! \brief Struct containing info for an AMI event to send out. */
+struct ast_manager_event_blob {
+ int event_flags; /*!< Flags the event should be raised with. */
+ const char *manager_event; /*!< The event to be raised, should be a string literal. */
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(extra_fields); /*!< Extra fields to include in the event. */
+ );
+};
+
+/*!
+ * \since 12
+ * \brief Construct a \ref snapshot_manager_event.
+ *
+ * \param event_flags Flags the event should be raised with.
+ * \param manager_event The event to be raised, should be a string literal.
+ * \param extra_fields_fmt Format string for extra fields to include.
+ * Or NO_EXTRA_FIELDS for no extra fields.
+ *
+ * \return New \ref ast_manager_snapshot_event object.
+ * \return \c NULL on error.
+ */
+struct ast_manager_event_blob *
+__attribute__((format(printf, 3, 4)))
+ast_manager_event_blob_create(
+ int event_flags,
+ const char *manager_event,
+ const char *extra_fields_fmt,
+ ...);
+
+/*! GCC warns about blank or NULL format strings. So, shenanigans! */
+#define NO_EXTRA_FIELDS "%s", ""
+
/*!
* \brief Initialize support for AMI channel events.
* \return 0 on success.
@@ -324,4 +356,12 @@
*/
int manager_channels_init(void);
+/*!
+ * \brief Initialize support for AMI channel events.
+ * \return 0 on success.
+ * \return non-zero on error.
+ * \since 12
+ */
+int manager_bridging_init(void);
+
#endif /* _ASTERISK_MANAGER_H */
Modified: team/rmudgett/bridge_phase/include/asterisk/strings.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/include/asterisk/strings.h?view=diff&rev=385382&r1=385381&r2=385382
==============================================================================
--- team/rmudgett/bridge_phase/include/asterisk/strings.h (original)
+++ team/rmudgett/bridge_phase/include/asterisk/strings.h Thu Apr 11 16:57:47 2013
@@ -29,6 +29,7 @@
#include "asterisk/utils.h"
#include "asterisk/threadstorage.h"
+#include "asterisk/astobj2.h"
#if defined(DEBUG_OPAQUE)
#define __AST_STR_USED used2
@@ -1013,4 +1014,26 @@
return abs(hash);
}
+/*!
+ * \since 12
+ * \brief Allocates a hash container for bare strings
+ *
+ * \param buckets The number of buckets to use for the hash container
+ *
+ * \retval AO2 container for strings
+ * \retval NULL if allocation failed
+ */
+struct ao2_container *ast_str_container_alloc(int buckets);
+
+/*!
+ * \since 12
+ * \brief Adds a string to a string container allocated by ast_str_container_alloc
+ *
+ * \param str_container The container to which to add a string
+ * \param add The string to add to the container
+ *
+ * \retval zero on success
+ * \retval non-zero if the operation failed
+ */
+int ast_str_container_add(struct ao2_container *str_container, const char *add);
#endif /* _ASTERISK_STRINGS_H */
Modified: team/rmudgett/bridge_phase/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/asterisk.c?view=diff&rev=385382&r1=385381&r2=385382
==============================================================================
--- team/rmudgett/bridge_phase/main/asterisk.c (original)
+++ team/rmudgett/bridge_phase/main/asterisk.c Thu Apr 11 16:57:47 2013
@@ -4220,11 +4220,6 @@
ast_http_init(); /* Start the HTTP server, if needed */
- if (init_manager()) {
- printf("%s", term_quit());
- exit(1);
- }
-
if (ast_cdr_engine_init()) {
printf("%s", term_quit());
exit(1);
@@ -4274,6 +4269,11 @@
}
if (ast_bridging_init()) {
+ printf("%s", term_quit());
+ exit(1);
+ }
+
+ if (init_manager()) {
printf("%s", term_quit());
exit(1);
}
Modified: team/rmudgett/bridge_phase/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/bridging.c?view=diff&rev=385382&r1=385381&r2=385382
==============================================================================
--- team/rmudgett/bridge_phase/main/bridging.c (original)
+++ team/rmudgett/bridge_phase/main/bridging.c Thu Apr 11 16:57:47 2013
@@ -40,6 +40,7 @@
#include "asterisk/lock.h"
#include "asterisk/linkedlists.h"
#include "asterisk/bridging.h"
+#include "asterisk/stasis_bridging.h"
#include "asterisk/bridging_technology.h"
#include "asterisk/app.h"
#include "asterisk/file.h"
@@ -521,6 +522,7 @@
bridge_dissolve_check(bridge_channel);
bridge->reconfigured = 1;
+ ast_bridge_publish_leave(bridge, bridge_channel->chan);
}
/*!
@@ -592,6 +594,7 @@
}
bridge->reconfigured = 1;
+ ast_bridge_publish_enter(bridge, bridge_channel->chan);
}
/*! \brief Internal function to handle DTMF from a channel */
@@ -1164,9 +1167,15 @@
static void destroy_bridge(void *obj)
{
struct ast_bridge *bridge = obj;
+ RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
ast_debug(1, "Bridge %s: actually destroying %s bridge, nobody wants it anymore\n",
bridge->uniqueid, bridge->v_table->name);
+
+ msg = stasis_cache_clear_create(ast_bridge_snapshot_type(), bridge->uniqueid);
+ if (msg) {
+ stasis_publish(ast_bridge_topic(bridge), msg);
+ }
/* Do any pending actions in the context of destruction. */
ast_bridge_lock(bridge);
@@ -1274,6 +1283,11 @@
return NULL;
}
+ if (!ast_bridge_topic(self)) {
+ ao2_ref(self, -1);
+ return NULL;
+ }
+
return self;
}
@@ -1396,6 +1410,9 @@
bridge = ast_bridge_alloc(sizeof(struct ast_bridge), &ast_bridge_base_v_table);
bridge = ast_bridge_base_init(bridge, capabilities, flags);
bridge = ast_bridge_register(bridge);
+ if (bridge) {
+ ast_bridge_publish_state(bridge);
+ }
return bridge;
}
@@ -3084,6 +3101,8 @@
ast_debug(1, "Merging bridge %s into bridge %s\n",
bridge2->uniqueid, bridge1->uniqueid);
+ ast_bridge_publish_merge(bridge1, bridge2);
+
/* Move channels from bridge2 over to bridge1 */
while ((bridge_channel = AST_LIST_FIRST(&bridge2->channels))) {
bridge_channel_pull(bridge_channel);
@@ -4508,10 +4527,16 @@
bridges = NULL;
ao2_cleanup(bridge_manager);
bridge_manager = NULL;
+ ast_stasis_bridging_shutdown();
}
int ast_bridging_init(void)
{
+ if (ast_stasis_bridging_init()) {
+ bridge_shutdown();
+ return -1;
+ }
+
bridge_manager = bridge_manager_create();
if (!bridge_manager) {
bridge_shutdown();
Modified: team/rmudgett/bridge_phase/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/manager.c?view=diff&rev=385382&r1=385381&r2=385382
==============================================================================
--- team/rmudgett/bridge_phase/main/manager.c (original)
+++ team/rmudgett/bridge_phase/main/manager.c Thu Apr 11 16:57:47 2013
@@ -7500,6 +7500,10 @@
return -1;
}
+ if (manager_bridging_init()) {
+ return -1;
+ }
+
if (!registered) {
/* Register default actions */
ast_manager_register_xml_core("Ping", 0, action_ping);
@@ -8010,3 +8014,45 @@
return datastore;
}
+
+static void manager_event_blob_dtor(void *obj)
+{
+ struct ast_manager_event_blob *ev = obj;
+ ast_string_field_free_memory(ev);
+}
+
+struct ast_manager_event_blob *
+__attribute__((format(printf, 3, 4)))
+ast_manager_event_blob_create(
+ int event_flags,
+ const char *manager_event,
+ const char *extra_fields_fmt,
+ ...)
+{
+ RAII_VAR(struct ast_manager_event_blob *, ev, NULL, ao2_cleanup);
+ va_list argp;
+
+ ast_assert(extra_fields_fmt != NULL);
+ ast_assert(manager_event != NULL);
+
+ ev = ao2_alloc(sizeof(*ev), manager_event_blob_dtor);
+ if (!ev) {
+ return NULL;
+ }
+
+ if (ast_string_field_init(ev, 20)) {
+ return NULL;
+ }
+
+ ev->manager_event = manager_event;
+ ev->event_flags = event_flags;
+
+ va_start(argp, extra_fields_fmt);
+ ast_string_field_ptr_build_va(ev, &ev->extra_fields, extra_fields_fmt,
+ argp);
+ va_end(argp);
+
+ ao2_ref(ev, +1);
+ return ev;
+}
+
Modified: team/rmudgett/bridge_phase/main/manager_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/manager_channels.c?view=diff&rev=385382&r1=385381&r2=385382
==============================================================================
--- team/rmudgett/bridge_phase/main/manager_channels.c (original)
+++ team/rmudgett/bridge_phase/main/manager_channels.c Thu Apr 11 16:57:47 2013
@@ -305,83 +305,18 @@
* \retval ast_str* on success (must be ast_freed by caller)
*/
static struct ast_str *manager_build_channel_state_string(
- const struct ast_channel_snapshot *snapshot)
+ const struct ast_channel_snapshot *snapshot)
{
return manager_build_channel_state_string_suffix(snapshot, "");
}
-/*! \brief Struct containing info for an AMI channel event to send out. */
-struct snapshot_manager_event {
- /*! event_flags manager_event() flags parameter. */
- int event_flags;
- /*! manager_event manager_event() category. */
- const char *manager_event;
- AST_DECLARE_STRING_FIELDS(
- /* extra fields to include in the event. */
- AST_STRING_FIELD(extra_fields);
- );
-};
-
-static void snapshot_manager_event_dtor(void *obj)
-{
- struct snapshot_manager_event *ev = obj;
- ast_string_field_free_memory(ev);
-}
-
-/*!
- * \brief Construct a \ref snapshot_manager_event.
- * \param event_flags manager_event() flags parameter.
- * \param manager_event manager_event() category.
- * \param extra_fields_fmt Format string for extra fields to include.
- * Or NO_EXTRA_FIELDS for no extra fields.
- * \return New \ref snapshot_manager_event object.
- * \return \c NULL on error.
- */
-static struct snapshot_manager_event *
-__attribute__((format(printf, 3, 4)))
-snapshot_manager_event_create(
- int event_flags,
- const char *manager_event,
- const char *extra_fields_fmt,
- ...)
-{
- RAII_VAR(struct snapshot_manager_event *, ev, NULL, ao2_cleanup);
- va_list argp;
-
- ast_assert(extra_fields_fmt != NULL);
- ast_assert(manager_event != NULL);
-
- ev = ao2_alloc(sizeof(*ev), snapshot_manager_event_dtor);
- if (!ev) {
- return NULL;
- }
-
- if (ast_string_field_init(ev, 20)) {
- return NULL;
- }
-
- ev->manager_event = manager_event;
- ev->event_flags = event_flags;
-
- va_start(argp, extra_fields_fmt);
- ast_string_field_ptr_build_va(ev, &ev->extra_fields, extra_fields_fmt,
- argp);
- va_end(argp);
-
- ao2_ref(ev, +1);
- return ev;
-}
-
-/*! GCC warns about blank or NULL format strings. So, shenanigans! */
-#define NO_EXTRA_FIELDS "%s", ""
-
/*! \brief Typedef for callbacks that get called on channel snapshot updates */
-typedef struct snapshot_manager_event *(*snapshot_monitor)(
+typedef struct ast_manager_event_blob *(*channel_snapshot_monitor)(
struct ast_channel_snapshot *old_snapshot,
struct ast_channel_snapshot *new_snapshot);
/*! \brief Handle channel state changes */
-static struct snapshot_manager_event *channel_state_change(
+static struct ast_manager_event_blob *channel_state_change(
struct ast_channel_snapshot *old_snapshot,
struct ast_channel_snapshot *new_snapshot)
{
@@ -398,7 +333,7 @@
*/
if (!old_snapshot) {
- return snapshot_manager_event_create(
+ return ast_manager_event_blob_create(
EVENT_FLAG_CALL, "Newchannel", NO_EXTRA_FIELDS);
}
@@ -406,7 +341,7 @@
is_hungup = ast_test_flag(&new_snapshot->flags, AST_FLAG_ZOMBIE) ? 1 : 0;
if (!was_hungup && is_hungup) {
- return snapshot_manager_event_create(
+ return ast_manager_event_blob_create(
EVENT_FLAG_CALL, "Hangup",
"Cause: %d\r\n"
"Cause-txt: %s\r\n",
@@ -415,7 +350,7 @@
}
if (old_snapshot->state != new_snapshot->state) {
- return snapshot_manager_event_create(
+ return ast_manager_event_blob_create(
EVENT_FLAG_CALL, "Newstate", NO_EXTRA_FIELDS);
}
@@ -451,7 +386,7 @@
strcmp(old_snapshot->exten, new_snapshot->exten) == 0;
}
-static struct snapshot_manager_event *channel_newexten(
+static struct ast_manager_event_blob *channel_newexten(
struct ast_channel_snapshot *old_snapshot,
struct ast_channel_snapshot *new_snapshot)
{
@@ -470,7 +405,7 @@
}
/* DEPRECATED: Extension field deprecated in 12; remove in 14 */
- return snapshot_manager_event_create(
+ return ast_manager_event_blob_create(
EVENT_FLAG_CALL, "Newexten",
"Extension: %s\r\n"
"Application: %s\r\n"
@@ -497,7 +432,7 @@
strcmp(old_snapshot->caller_name, new_snapshot->caller_name) == 0;
}
-static struct snapshot_manager_event *channel_new_callerid(
+static struct ast_manager_event_blob *channel_new_callerid(
struct ast_channel_snapshot *old_snapshot,
struct ast_channel_snapshot *new_snapshot)
{
@@ -510,14 +445,14 @@
return NULL;
}
- return snapshot_manager_event_create(
+ return ast_manager_event_blob_create(
EVENT_FLAG_CALL, "NewCallerid",
"CID-CallingPres: %d (%s)\r\n",
new_snapshot->caller_pres,
ast_describe_caller_presentation(new_snapshot->caller_pres));
}
-snapshot_monitor monitors[] = {
+channel_snapshot_monitor channel_monitors[] = {
channel_state_change,
channel_newexten,
channel_new_callerid
@@ -542,9 +477,9 @@
old_snapshot = stasis_message_data(update->old_snapshot);
new_snapshot = stasis_message_data(update->new_snapshot);
- for (i = 0; i < ARRAY_LEN(monitors); ++i) {
- RAII_VAR(struct snapshot_manager_event *, ev, NULL, ao2_cleanup);
- ev = monitors[i](old_snapshot, new_snapshot);
+ for (i = 0; i < ARRAY_LEN(channel_monitors); ++i) {
+ RAII_VAR(struct ast_manager_event_blob *, ev, NULL, ao2_cleanup);
+ ev = channel_monitors[i](old_snapshot, new_snapshot);
if (!ev) {
continue;
Modified: team/rmudgett/bridge_phase/main/strings.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/strings.c?view=diff&rev=385382&r1=385381&r2=385382
==============================================================================
--- team/rmudgett/bridge_phase/main/strings.c (original)
+++ team/rmudgett/bridge_phase/main/strings.c Thu Apr 11 16:57:47 2013
@@ -160,3 +160,30 @@
return (*buf)->__AST_STR_STR;
}
+static int str_hash(const void *obj, const int flags)
+{
+ return ast_str_hash(obj);
+}
+
+static int str_cmp(void *lhs, void *rhs, int flags)
+{
+ return strcmp(lhs, rhs) ? 0 : CMP_MATCH;
+}
+
+struct ao2_container *ast_str_container_alloc(int buckets)
+{
+ return ao2_container_alloc(buckets, str_hash, str_cmp);
+}
+
+int ast_str_container_add(struct ao2_container *str_container, const char *add)
+{
+ RAII_VAR(char *, ao2_add, ao2_alloc(strlen(add) + 1, NULL), ao2_cleanup);
+
+ if (!ao2_add) {
+ return -1;
+ }
+
+ /* safe strcpy */
+ strcpy(ao2_add, add);
+ return ao2_link(str_container, ao2_add);
+}
More information about the asterisk-commits
mailing list