[asterisk-commits] kmoore: branch kmoore/event_system_strip r395313 - in /team/kmoore/event_syst...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 24 15:20:46 CDT 2013


Author: kmoore
Date: Wed Jul 24 15:20:44 2013
New Revision: 395313

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395313
Log:
Pull out some more of the cache functionality

Modified:
    team/kmoore/event_system_strip/include/asterisk/event.h
    team/kmoore/event_system_strip/main/event.c
    team/kmoore/event_system_strip/tests/test_event.c

Modified: team/kmoore/event_system_strip/include/asterisk/event.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/include/asterisk/event.h?view=diff&rev=395313&r1=395312&r2=395313
==============================================================================
--- team/kmoore/event_system_strip/include/asterisk/event.h (original)
+++ team/kmoore/event_system_strip/include/asterisk/event.h Wed Jul 24 15:20:44 2013
@@ -379,23 +379,6 @@
 int ast_event_queue(struct ast_event *event);
 
 /*!
- * \brief Queue and cache an event
- *
- * \param event the event to be queued and cached
- *
- * \details
- * The purpose of caching events is so that the core can retain the last known
- * information for events that represent some sort of state.  That way, when
- * code needs to find out the current state, it can query the cache.
- *
- * The event API already knows which events can be cached and how to cache them.
- *
- * \retval 0 success
- * \retval non-zero failure.
- */
-int ast_event_queue_and_cache(struct ast_event *event);
-
-/*!
  * \brief Append an information element that has a string payload
  *
  * \param event the event that the IE will be appended to

Modified: team/kmoore/event_system_strip/main/event.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/main/event.c?view=diff&rev=395313&r1=395312&r2=395313
==============================================================================
--- team/kmoore/event_system_strip/main/event.c (original)
+++ team/kmoore/event_system_strip/main/event.c Wed Jul 24 15:20:44 2013
@@ -1373,7 +1373,7 @@
 	return 0;
 }
 
-static int _ast_event_queue(struct ast_event *event, unsigned int cache)
+int ast_event_queue(struct ast_event *event)
 {
 	struct ast_event_ref *event_ref;
 	uint16_t host_event_type;
@@ -1400,7 +1400,7 @@
 	}
 
 	event_ref->event = event;
-	event_ref->cache = cache;
+	event_ref->cache = 0;
 
 	res = ast_taskprocessor_push(event_dispatcher, handle_event, event_ref);
 	if (res) {
@@ -1408,16 +1408,6 @@
 		ao2_ref(event_ref, -1);
 	}
 	return res;
-}
-
-int ast_event_queue(struct ast_event *event)
-{
-	return _ast_event_queue(event, 0);
-}
-
-int ast_event_queue_and_cache(struct ast_event *event)
-{
-	return _ast_event_queue(event, 1);
 }
 
 static int ast_event_hash(const void *obj, const int flags)
@@ -1485,139 +1475,11 @@
 	return res;
 }
 
-static void dump_raw_ie(struct ast_event_iterator *i, struct ast_cli_args *a)
-{
-	char eid_buf[32];
-	enum ast_event_ie_type ie_type;
-	const char *ie_type_name;
-
-	ie_type = ast_event_iterator_get_ie_type(i);
-	ie_type_name = ast_event_get_ie_type_name(ie_type);
-
-	switch (ie_type) {
-	case AST_EVENT_IE_EID:
-		ast_eid_to_str(eid_buf, sizeof(eid_buf), ast_event_iterator_get_ie_raw(i));
-		ast_cli(a->fd, "%.30s: %s\n", ie_type_name, eid_buf);
-		break;
-	default:
-		ast_cli(a->fd, "%s\n", ie_type_name);
-		break;
-	}
-}
-
-static int event_dump_cli(void *obj, void *arg, int flags)
-{
-	const struct ast_event_ref *event_ref = obj;
-	const struct ast_event *event = event_ref->event;
-	struct ast_cli_args *a = arg;
-	struct ast_event_iterator i;
-
-	if (ast_event_iterator_init(&i, event)) {
-		ast_cli(a->fd, "Failed to initialize event iterator.  :-(\n");
-		return 0;
-	}
-
-	ast_cli(a->fd, "Event: %s\n", ast_event_get_type_name(event));
-
-	do {
-		enum ast_event_ie_type ie_type;
-		enum ast_event_ie_pltype ie_pltype;
-		const char *ie_type_name;
-
-		ie_type = ast_event_iterator_get_ie_type(&i);
-		ie_type_name = ast_event_get_ie_type_name(ie_type);
-		ie_pltype = ast_event_get_ie_pltype(ie_type);
-
-		switch (ie_pltype) {
-		case AST_EVENT_IE_PLTYPE_UNKNOWN:
-		case AST_EVENT_IE_PLTYPE_EXISTS:
-			ast_cli(a->fd, "%s\n", ie_type_name);
-			break;
-		case AST_EVENT_IE_PLTYPE_STR:
-			ast_cli(a->fd, "%.30s: %s\n", ie_type_name,
-					ast_event_iterator_get_ie_str(&i));
-			break;
-		case AST_EVENT_IE_PLTYPE_UINT:
-			ast_cli(a->fd, "%.30s: %u\n", ie_type_name,
-					ast_event_iterator_get_ie_uint(&i));
-			break;
-		case AST_EVENT_IE_PLTYPE_BITFLAGS:
-			ast_cli(a->fd, "%.30s: %u\n", ie_type_name,
-					ast_event_iterator_get_ie_bitflags(&i));
-			break;
-		case AST_EVENT_IE_PLTYPE_RAW:
-			dump_raw_ie(&i, a);
-			break;
-		}
-	} while (!ast_event_iterator_next(&i));
-
-	ast_cli(a->fd, "\n");
-
-	return 0;
-}
-
-static char *event_dump_cache(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	enum ast_event_type event_type;
-	enum ast_event_ie_type *cache_args;
-	int i;
-
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "event dump cache";
-		e->usage =
-			"Usage: event dump cache <event type>\n"
-			"       Dump all of the cached events for the given event type.\n"
-			"       This is primarily intended for debugging.\n";
-		return NULL;
-	case CLI_GENERATE:
-		if (a->pos == 3) {
-			return ast_cli_complete(a->word, cached_event_types, a->n);
-		}
-		return NULL;
-	case CLI_HANDLER:
-		break;
-	}
-
-	if (a->argc != e->args + 1) {
-		return CLI_SHOWUSAGE;
-	}
-
-	if (ast_event_str_to_event_type(a->argv[e->args], &event_type)) {
-		ast_cli(a->fd, "Invalid cached event type: '%s'\n", a->argv[e->args]);
-		return CLI_SHOWUSAGE;
-	}
-
-	if (!ast_event_cache[event_type].container) {
-		ast_cli(a->fd, "Event type '%s' has no cache.\n", a->argv[e->args]);
-		return CLI_SUCCESS;
-	}
-
-	ast_cli(a->fd, "Event Type: %s\n", a->argv[e->args]);
-	ast_cli(a->fd, "Cache Unique Keys:\n");
-	cache_args = ast_event_cache[event_type].cache_args;
-	for (i = 0; i < ARRAY_LEN(ast_event_cache[0].cache_args) && cache_args[i]; i++) {
-		ast_cli(a->fd, "--> %s\n", ast_event_get_ie_type_name(cache_args[i]));
-	}
-
-	ast_cli(a->fd, "\n--- Begin Cache Dump ---\n\n");
-	ao2_callback(ast_event_cache[event_type].container, OBJ_NODATA, event_dump_cli, a);
-	ast_cli(a->fd, "--- End Cache Dump ---\n\n");
-
-	return CLI_SUCCESS;
-}
-
-static struct ast_cli_entry event_cli[] = {
-	AST_CLI_DEFINE(event_dump_cache, "Dump the internal event cache (for debugging)"),
-};
-
 /*! \internal \brief Clean up resources on Asterisk shutdown */
 static void event_shutdown(void)
 {
 	struct ast_event_sub *sub;
 	int i;
-
-	ast_cli_unregister_multiple(event_cli, ARRAY_LEN(event_cli));
 
 	if (event_dispatcher) {
 		event_dispatcher = ast_taskprocessor_unreference(event_dispatcher);
@@ -1669,8 +1531,6 @@
 		goto event_init_cleanup;
 	}
 
-	ast_cli_register_multiple(event_cli, ARRAY_LEN(event_cli));
-
 	ast_register_atexit(event_shutdown);
 
 	return 0;

Modified: team/kmoore/event_system_strip/tests/test_event.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/tests/test_event.c?view=diff&rev=395313&r1=395312&r2=395313
==============================================================================
--- team/kmoore/event_system_strip/tests/test_event.c (original)
+++ team/kmoore/event_system_strip/tests/test_event.c Wed Jul 24 15:20:44 2013
@@ -25,7 +25,6 @@
  * \ingroup tests
  *
  * \todo API Calls not yet touched by a test: XXX TODO
- *   - ast_event_queue_and_cache()
  *   - ast_event_report_subs()
  *   - ast_event_get_ie_type_name()
  *   - ast_event_get_ie_pltype()




More information about the asterisk-commits mailing list