[asterisk-commits] kmoore: branch kmoore/cel_backend_refactor r396837 - in /team/kmoore/cel_back...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 16 08:24:34 CDT 2013


Author: kmoore
Date: Fri Aug 16 08:24:32 2013
New Revision: 396837

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396837
Log:
Address review issues

Modified:
    team/kmoore/cel_backend_refactor/cel/cel_pgsql.c
    team/kmoore/cel_backend_refactor/main/cel.c

Modified: team/kmoore/cel_backend_refactor/cel/cel_pgsql.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_backend_refactor/cel/cel_pgsql.c?view=diff&rev=396837&r1=396836&r2=396837
==============================================================================
--- team/kmoore/cel_backend_refactor/cel/cel_pgsql.c (original)
+++ team/kmoore/cel_backend_refactor/cel/cel_pgsql.c Fri Aug 16 08:24:32 2013
@@ -559,7 +559,7 @@
 	process_my_load_module(cfg);
 	ast_config_destroy(cfg);
 
-	if (ast_cel_backend_unregister(PGSQL_BACKEND_NAME, pgsql_log)) {
+	if (ast_cel_backend_register(PGSQL_BACKEND_NAME, pgsql_log)) {
 		ast_log(LOG_WARNING, "Unable to subscribe to CEL events for pgsql\n");
 		return AST_MODULE_LOAD_DECLINE;
 	}

Modified: team/kmoore/cel_backend_refactor/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_backend_refactor/main/cel.c?view=diff&rev=396837&r1=396836&r2=396837
==============================================================================
--- team/kmoore/cel_backend_refactor/main/cel.c (original)
+++ team/kmoore/cel_backend_refactor/main/cel.c Fri Aug 16 08:24:32 2013
@@ -147,7 +147,7 @@
 /*! Container for primary channel/bridge ID listing for 2 party bridges */
 static struct ao2_container *bridge_primaries;
 
-/*! The number of buckets into which primary channel uniqueids will be hashed */
+/*! The number of buckets into which bridge primary structs will be hashed */
 #define BRIDGE_PRIMARY_BUCKETS 251
 
 struct stasis_message_type *cel_generic_type(void);
@@ -337,11 +337,21 @@
 /*! \brief Hashing function for cel_backend */
 static int cel_backend_hash(const void *obj, int flags)
 {
-	const struct cel_backend *backend = obj;
-	const char *name = obj;
-
-	if (!(flags & OBJ_KEY)) {
+	const struct cel_backend *backend;
+	const char *name;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	case OBJ_POINTER:
+		backend = obj;
 		name = backend->name;
+		break;
+	case OBJ_KEY:
+		name = obj;
+		break;
+	default:
+		/* Hash can only work on something with a full key. */
+		ast_assert(0);
+		return 0;
 	}
 
 	return ast_str_hash(name);
@@ -350,11 +360,21 @@
 /*! \brief Comparator function for cel_backend */
 static int cel_backend_cmp(void *obj, void *arg, int flags)
 {
-	struct cel_backend *backend1 = obj, *backend2 = arg;
-	const char *backend2_id = arg, *backend1_id = backend1->name;
-
-	if (!(flags & OBJ_KEY)) {
+	struct cel_backend *backend2, *backend1 = obj;
+	const char *backend2_id, *backend1_id = backend1->name;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	case OBJ_POINTER:
+		backend2 = arg;
 		backend2_id = backend2->name;
+		break;
+	case OBJ_KEY:
+		backend2_id = arg;
+		break;
+	default:
+		/* Hash can only work on something with a full key. */
+		ast_assert(0);
+		return 0;
 	}
 
 	return !strcmp(backend1_id, backend2_id) ? CMP_MATCH | CMP_STOP : 0;




More information about the asterisk-commits mailing list