[asterisk-commits] russell: branch russell/ais r78413 - in /team/russell/ais: apps/ include/aste...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 7 13:56:17 CDT 2007


Author: russell
Date: Tue Aug  7 13:56:16 2007
New Revision: 78413

URL: http://svn.digium.com/view/asterisk?view=rev&rev=78413
Log:
add an API call to dump the contents of the cache for an event subscriber and use it in res_ais

Modified:
    team/russell/ais/apps/app_voicemail.c
    team/russell/ais/include/asterisk/event.h
    team/russell/ais/main/event.c
    team/russell/ais/res/res_ais.c

Modified: team/russell/ais/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/russell/ais/apps/app_voicemail.c?view=diff&rev=78413&r1=78412&r2=78413
==============================================================================
--- team/russell/ais/apps/app_voicemail.c (original)
+++ team/russell/ais/apps/app_voicemail.c Tue Aug  7 13:56:16 2007
@@ -4117,6 +4117,8 @@
 			AST_EVENT_IE_END))) {
 		return;
 	}
+
+	ast_log(LOG_DEBUG, "Queueing event for mailbox %s\n", mailbox);
 
 	ast_event_queue_and_cache(event,
 		AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR,

Modified: team/russell/ais/include/asterisk/event.h
URL: http://svn.digium.com/view/asterisk/team/russell/ais/include/asterisk/event.h?view=diff&rev=78413&r1=78412&r2=78413
==============================================================================
--- team/russell/ais/include/asterisk/event.h (original)
+++ team/russell/ais/include/asterisk/event.h Tue Aug  7 13:56:16 2007
@@ -170,6 +170,9 @@
  */
 void ast_event_report_subs(const struct ast_event_sub *sub);
 
+/*! \brief Dump the event cache for the subscriber */
+void ast_event_dump_cache(const struct ast_event_sub *event_sub);
+
 /*!
  * \brief Create a new event
  *

Modified: team/russell/ais/main/event.c
URL: http://svn.digium.com/view/asterisk/team/russell/ais/main/event.c?view=diff&rev=78413&r1=78412&r2=78413
==============================================================================
--- team/russell/ais/main/event.c (original)
+++ team/russell/ais/main/event.c Tue Aug  7 13:56:16 2007
@@ -195,6 +195,39 @@
 	return res;
 }
 
+/*! \brief Dump the event cache for the subscribed event type */
+void ast_event_dump_cache(const struct ast_event_sub *event_sub)
+{
+	struct ast_event_ref *event_ref;
+	enum ast_event_type type = event_sub->type;
+
+	AST_RWLIST_RDLOCK(&ast_event_cache[type]);
+	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&ast_event_cache[type], event_ref, entry) {
+		struct ast_event_ie_val *ie_val;
+		AST_LIST_TRAVERSE(&event_sub->ie_vals, ie_val, entry) {
+			if ( ! ( (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_UINT &&
+			   (ie_val->payload.uint ==
+			    ast_event_get_ie_uint(event_ref->event, ie_val->ie_type))) ||
+
+			   (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_STR &&
+			   (!strcmp(ie_val->payload.str,
+			     ast_event_get_ie_str(event_ref->event, ie_val->ie_type)))) ||
+
+			   (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_EXISTS &&
+			    ast_event_get_ie_raw(event_ref->event, ie_val->ie_type)) ) ) 
+			{
+				break;
+			}
+		}
+		if (!ie_val) {
+			/* All parameters were matched on this cache entry, so dump it */
+			event_sub->cb(event_ref->event, event_sub->userdata);
+		}
+	}
+	AST_RWLIST_TRAVERSE_SAFE_END
+	AST_RWLIST_UNLOCK(&ast_event_cache[type]);
+}
+
 /*! \brief Send AST_EVENT_SUB events to this subscriber of ... subscriber events */
 void ast_event_report_subs(const struct ast_event_sub *event_sub)
 {

Modified: team/russell/ais/res/res_ais.c
URL: http://svn.digium.com/view/asterisk/team/russell/ais/res/res_ais.c?view=diff&rev=78413&r1=78412&r2=78413
==============================================================================
--- team/russell/ais/res/res_ais.c (original)
+++ team/russell/ais/res/res_ais.c Tue Aug  7 13:56:16 2007
@@ -267,14 +267,18 @@
 	const char *filter_str;
 	SaEvtEventIdT event_id;
 
+	ast_log(LOG_DEBUG, "Got an event to forward\n");
+
 	if (strcasecmp(g_eid_str, ast_event_get_ie_str(ast_event, AST_EVENT_IE_EID))) {
 		/* If the event didn't originate from this server, don't send it back out. */
+		ast_log(LOG_DEBUG, "Returning here\n");
 		return;
 	}
 
 	res = saEvtEventAllocate(event_channel->handle, &event_handle);
 	if (res != SA_AIS_OK) {
 		ast_log(LOG_ERROR, "Error allocating event: %s\n", ais_err2str(res));
+		ast_log(LOG_DEBUG, "Returning here\n");
 		return;
 	}
 	
@@ -318,6 +322,7 @@
 	if (res != SA_AIS_OK) {
 		ast_log(LOG_ERROR, "Error freeing allocated event: %s\n", ais_err2str(res));
 	}
+	ast_log(LOG_DEBUG, "Returning here (event_free)\n");
 }
 
 static void *dispatch_thread(void *data)
@@ -488,9 +493,10 @@
 		return;
 	
 	publish_event->type = type;
-
+	ast_log(LOG_DEBUG, "Subscribing to event type %d\n", type);
 	publish_event->sub = ast_event_subscribe(type, ast_event_cb, event_channel,
 		AST_EVENT_IE_END);
+	ast_event_dump_cache(publish_event->sub);
 
 	AST_LIST_INSERT_TAIL(&event_channel->publish_events, publish_event, entry);
 }




More information about the asterisk-commits mailing list