[asterisk-commits] mjordan: branch mjordan/12-corosync r413034 - in /team/mjordan/12-corosync: i...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Apr 26 22:58:03 CDT 2014
Author: mjordan
Date: Sat Apr 26 22:57:56 2014
New Revision: 413034
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=413034
Log:
Add some debug, clean up errors
Modified:
team/mjordan/12-corosync/include/asterisk/event.h
team/mjordan/12-corosync/main/app.c
team/mjordan/12-corosync/main/event.c
team/mjordan/12-corosync/main/stasis.c
team/mjordan/12-corosync/res/res_corosync.c
Modified: team/mjordan/12-corosync/include/asterisk/event.h
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-corosync/include/asterisk/event.h?view=diff&rev=413034&r1=413033&r2=413034
==============================================================================
--- team/mjordan/12-corosync/include/asterisk/event.h (original)
+++ team/mjordan/12-corosync/include/asterisk/event.h Sat Apr 26 22:57:56 2014
@@ -244,6 +244,16 @@
uint16_t ast_event_get_ie_raw_payload_len(const struct ast_event *event, enum ast_event_ie_type ie_type);
/*!
+ * \brief Get the string representation of the type of the given event
+ *
+ * \arg event the event to get the type of
+ *
+ * \return the string representation of the event type of the provided event
+ * \since 1.6.1
+ */
+const char *ast_event_get_type_name(const struct ast_event *event);
+
+/*!
* \brief Get the string representation of an information element type
*
* \param ie_type the information element type to get the string representation of
Modified: team/mjordan/12-corosync/main/app.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-corosync/main/app.c?view=diff&rev=413034&r1=413033&r2=413034
==============================================================================
--- team/mjordan/12-corosync/main/app.c (original)
+++ team/mjordan/12-corosync/main/app.c Sat Apr 26 22:57:56 2014
@@ -122,7 +122,7 @@
AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, mwi_state->new_msgs,
AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, mwi_state->old_msgs,
- AST_EVENT_IE_EID, AST_EVENT_IE_PLTYPE_RAW, mwi_state->eid, sizeof(mwi_state->eid),
+ AST_EVENT_IE_EID, AST_EVENT_IE_PLTYPE_RAW, &mwi_state->eid, sizeof(mwi_state->eid),
AST_EVENT_IE_END);
return event;
Modified: team/mjordan/12-corosync/main/event.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-corosync/main/event.c?view=diff&rev=413034&r1=413033&r2=413034
==============================================================================
--- team/mjordan/12-corosync/main/event.c (original)
+++ team/mjordan/12-corosync/main/event.c Sat Apr 26 22:57:56 2014
@@ -105,19 +105,42 @@
size_t raw_datalen;
};
-struct ie_map {
+/*!
+ * \brief Event Names
+ */
+static const char * const event_names[AST_EVENT_TOTAL] = {
+ [AST_EVENT_ALL] = "All",
+ [AST_EVENT_CUSTOM] = "Custom",
+ [AST_EVENT_MWI] = "MWI",
+ [AST_EVENT_SUB] = "Subscription",
+ [AST_EVENT_UNSUB] = "Unsubscription",
+ [AST_EVENT_DEVICE_STATE] = "DeviceState",
+ [AST_EVENT_DEVICE_STATE_CHANGE] = "DeviceStateChange",
+ [AST_EVENT_CEL] = "CEL",
+ [AST_EVENT_SECURITY] = "Security",
+ [AST_EVENT_NETWORK_CHANGE] = "NetworkChange",
+ [AST_EVENT_PRESENCE_STATE] = "PresenceState",
+ [AST_EVENT_ACL_CHANGE] = "ACLChange",
+ [AST_EVENT_PING] = "Ping",
+};
+
+/*!
+ * \brief IE payload types and names
+ */
+static const struct ie_map {
enum ast_event_ie_pltype ie_pltype;
const char *name;
-};
-
-/*!
- * \brief IE payload types and names
- */
-static const struct ie_map ie_maps[AST_EVENT_IE_TOTAL] = {
+} ie_maps[AST_EVENT_IE_TOTAL] = {
+ [AST_EVENT_IE_NEWMSGS] = { AST_EVENT_IE_PLTYPE_UINT, "NewMessages" },
+ [AST_EVENT_IE_OLDMSGS] = { AST_EVENT_IE_PLTYPE_UINT, "OldMessages" },
+ [AST_EVENT_IE_MAILBOX] = { AST_EVENT_IE_PLTYPE_STR, "Mailbox" },
[AST_EVENT_IE_UNIQUEID] = { AST_EVENT_IE_PLTYPE_UINT, "UniqueID" },
[AST_EVENT_IE_EVENTTYPE] = { AST_EVENT_IE_PLTYPE_UINT, "EventType" },
[AST_EVENT_IE_EXISTS] = { AST_EVENT_IE_PLTYPE_UINT, "Exists" },
+ [AST_EVENT_IE_DEVICE] = { AST_EVENT_IE_PLTYPE_STR, "Device" },
+ [AST_EVENT_IE_STATE] = { AST_EVENT_IE_PLTYPE_UINT, "State" },
[AST_EVENT_IE_CONTEXT] = { AST_EVENT_IE_PLTYPE_STR, "Context" },
+ [AST_EVENT_IE_EID] = { AST_EVENT_IE_PLTYPE_RAW, "EntityID" },
[AST_EVENT_IE_CEL_EVENT_TYPE] = { AST_EVENT_IE_PLTYPE_UINT, "CELEventType" },
[AST_EVENT_IE_CEL_EVENT_TIME] = { AST_EVENT_IE_PLTYPE_UINT, "CELEventTime" },
[AST_EVENT_IE_CEL_EVENT_TIME_USEC] = { AST_EVENT_IE_PLTYPE_UINT, "CELEventTimeUSec" },
@@ -140,6 +163,7 @@
[AST_EVENT_IE_CEL_LINKEDID] = { AST_EVENT_IE_PLTYPE_STR, "CELLinkedID" },
[AST_EVENT_IE_CEL_PEERACCT] = { AST_EVENT_IE_PLTYPE_STR, "CELPeerAcct" },
[AST_EVENT_IE_CEL_EXTRA] = { AST_EVENT_IE_PLTYPE_STR, "CELExtra" },
+ [AST_EVENT_IE_SECURITY_EVENT] = { AST_EVENT_IE_PLTYPE_STR, "SecurityEvent" },
[AST_EVENT_IE_EVENT_VERSION] = { AST_EVENT_IE_PLTYPE_UINT, "EventVersion" },
[AST_EVENT_IE_SERVICE] = { AST_EVENT_IE_PLTYPE_STR, "Service" },
[AST_EVENT_IE_MODULE] = { AST_EVENT_IE_PLTYPE_STR, "Module" },
@@ -162,7 +186,26 @@
[AST_EVENT_IE_RECEIVED_HASH] = { AST_EVENT_IE_PLTYPE_STR, "ReceivedHash" },
[AST_EVENT_IE_USING_PASSWORD] = { AST_EVENT_IE_PLTYPE_UINT, "UsingPassword" },
[AST_EVENT_IE_ATTEMPTED_TRANSPORT] = { AST_EVENT_IE_PLTYPE_STR, "AttemptedTransport" },
+ [AST_EVENT_IE_CACHABLE] = { AST_EVENT_IE_PLTYPE_UINT, "Cachable" },
+ [AST_EVENT_IE_PRESENCE_PROVIDER] = { AST_EVENT_IE_PLTYPE_STR, "PresenceProvider" },
+ [AST_EVENT_IE_PRESENCE_STATE] = { AST_EVENT_IE_PLTYPE_UINT, "PresenceState" },
+ [AST_EVENT_IE_PRESENCE_SUBTYPE] = { AST_EVENT_IE_PLTYPE_STR, "PresenceSubtype" },
+ [AST_EVENT_IE_PRESENCE_MESSAGE] = { AST_EVENT_IE_PLTYPE_STR, "PresenceMessage" },
};
+
+const char *ast_event_get_type_name(const struct ast_event *event)
+{
+ enum ast_event_type type;
+
+ type = ast_event_get_type(event);
+
+ if (type < 0 || type >= ARRAY_LEN(event_names)) {
+ ast_log(LOG_ERROR, "Invalid event type - '%d'\n", type);
+ return "";
+ }
+
+ return event_names[type];
+}
const char *ast_event_get_ie_type_name(enum ast_event_ie_type ie_type)
{
Modified: team/mjordan/12-corosync/main/stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-corosync/main/stasis.c?view=diff&rev=413034&r1=413033&r2=413034
==============================================================================
--- team/mjordan/12-corosync/main/stasis.c (original)
+++ team/mjordan/12-corosync/main/stasis.c Sat Apr 26 22:57:56 2014
@@ -721,7 +721,7 @@
/* Forwards to ourselves are implicit. */
if (to_topic == from_topic) {
- return forward;
+ return ao2_bump(forward);
}
forward->from_topic = ao2_bump(from_topic);
Modified: team/mjordan/12-corosync/res/res_corosync.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-corosync/res/res_corosync.c?view=diff&rev=413034&r1=413033&r2=413034
==============================================================================
--- team/mjordan/12-corosync/res/res_corosync.c (original)
+++ team/mjordan/12-corosync/res/res_corosync.c Sat Apr 26 22:57:56 2014
@@ -330,14 +330,16 @@
memcpy(event, msg, msg_len);
- if (ast_event_get_type(event) == AST_EVENT_PING) {
+ if (event_type == AST_EVENT_PING) {
const struct ast_eid *eid;
char buf[128] = "";
eid = ast_event_get_ie_raw(event, AST_EVENT_IE_EID);
ast_eid_to_str(buf, sizeof(buf), (struct ast_eid *) eid);
- ast_log(LOG_NOTICE, "(cpg_deliver_cb) Got event PING from server with EID: '%s'\n", buf);
- }
+ ast_log(LOG_NOTICE, "Got event PING from server with EID: '%s'\n", buf);
+ }
+ ast_debug(5, "Publishing event %s (%d) to stasis\n",
+ ast_event_get_type_name(event), event_type);
publish_handler(event);
}
@@ -365,7 +367,7 @@
eid = ast_event_get_ie_raw(event, AST_EVENT_IE_EID);
ast_eid_to_str(buf, sizeof(buf), (struct ast_eid *) eid);
- ast_log(LOG_NOTICE, "(publish_to_corosync) Sending event PING from this server with EID: '%s'\n", buf);
+ ast_log(LOG_NOTICE, "Sending event PING from this server with EID: '%s'\n", buf);
}
iov.iov_base = (void *)event;
@@ -757,7 +759,6 @@
NULL);
} else if (!event_types[i].publish && event_types[i].sub && event_types[i].topic_fn) {
event_types[i].sub = stasis_forward_cancel(event_types[i].sub);
- event_types[i].sub = NULL;
stasis_message_router_remove(stasis_router,
event_types[i].message_type_fn());
}
More information about the asterisk-commits
mailing list