[asterisk-commits] mjordan: branch mjordan/trunk-astdb-cluster r433716 - in /team/mjordan/trunk-...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Mar 28 11:18:28 CDT 2015


Author: mjordan
Date: Sat Mar 28 11:18:22 2015
New Revision: 433716

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433716
Log:
Resolve review findings from rmudgett

Modified:
    team/mjordan/trunk-astdb-cluster/funcs/func_db.c
    team/mjordan/trunk-astdb-cluster/include/asterisk/astdb.h
    team/mjordan/trunk-astdb-cluster/main/db.c
    team/mjordan/trunk-astdb-cluster/res/res_pjsip_publish_asterisk.c

Modified: team/mjordan/trunk-astdb-cluster/funcs/func_db.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-astdb-cluster/funcs/func_db.c?view=diff&rev=433716&r1=433715&r2=433716
==============================================================================
--- team/mjordan/trunk-astdb-cluster/funcs/func_db.c (original)
+++ team/mjordan/trunk-astdb-cluster/funcs/func_db.c Sat Mar 28 11:18:22 2015
@@ -230,7 +230,7 @@
 		</syntax>
 		<description>
 			<para>This function will check to see if a family is shared between
-			Asteris instances. If so, the function will return <literal>1</literal>.
+			Asterisk instances. If so, the function will return <literal>1</literal>.
 			If not, it will return <literal>0</literal>.</para>
 		</description>
 		<see-also>

Modified: team/mjordan/trunk-astdb-cluster/include/asterisk/astdb.h
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-astdb-cluster/include/asterisk/astdb.h?view=diff&rev=433716&r1=433715&r2=433716
==============================================================================
--- team/mjordan/trunk-astdb-cluster/include/asterisk/astdb.h (original)
+++ team/mjordan/trunk-astdb-cluster/include/asterisk/astdb.h Sat Mar 28 11:18:22 2015
@@ -34,7 +34,7 @@
 struct stasis_message_type;
 
 enum ast_db_shared_type {
-	/* Items in the shared family are common across all Asterisk instances */
+	/*! Items in the shared family are common across all Asterisk instances */
 	DB_SHARE_TYPE_GLOBAL = 0,
 	/*! Items in the shared family are made unique across all Asterisk instances */
 	DB_SHARE_TYPE_UNIQUE,

Modified: team/mjordan/trunk-astdb-cluster/main/db.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-astdb-cluster/main/db.c?view=diff&rev=433716&r1=433715&r2=433716
==============================================================================
--- team/mjordan/trunk-astdb-cluster/main/db.c (original)
+++ team/mjordan/trunk-astdb-cluster/main/db.c Sat Mar 28 11:18:22 2015
@@ -243,7 +243,7 @@
 	struct ast_db_shared_family *shared_family;
 
 	shared_family = ao2_alloc_options(sizeof(*shared_family) + strlen(family) + 1,
-		shared_db_family_dtor, OBJ_NOLOCK);
+		shared_db_family_dtor, AO2_ALLOC_OPT_LOCK_NOLOCK);
 	if (!shared_family) {
 		return NULL;
 	}
@@ -275,16 +275,19 @@
 	const char *right_key = obj_right;
 	int cmp;
 
-	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
-	default:
-	case OBJ_POINTER:
+	switch (flags & OBJ_SEARCH_MASK) {
+	case OBJ_SEARCH_OBJECT:
 		right_key = right->name;
 		/* Fall through */
-	case OBJ_KEY:
+	case OBJ_SEARCH_KEY:
 		cmp = strcmp(left->name, right_key);
 		break;
-	case OBJ_PARTIAL_KEY:
+	case OBJ_SEARCH_PARTIAL_KEY:
 		cmp = strncmp(left->name, right_key, strlen(right_key));
+		break;
+	default:
+		ast_assert(0);
+		cmp = 0;
 		break;
 	}
 	return cmp;
@@ -488,6 +491,7 @@
 	ast_db_publish_shared_message(ast_db_put_shared_type(), clone, NULL);
 
 	ao2_ref(shared_family, -1);
+	ao2_ref(clone, -1);
 
 	return 0;
 }
@@ -534,6 +538,7 @@
 	ast_db_publish_shared_message(ast_db_del_shared_type(), clone, NULL);
 
 	ao2_ref(shared_family, -1);
+	ao2_ref(clone, -1);
 
 	return 0;
 }
@@ -1530,7 +1535,7 @@
 	}
 
 	/* Don't update if we don't have this area shared on this server */
-	shared_check = ao2_find(shared_families, shared_family->name, OBJ_KEY);
+	shared_check = ao2_find(shared_families, shared_family->name, OBJ_SEARCH_KEY);
 	if (!shared_check) {
 		return;
 	}

Modified: team/mjordan/trunk-astdb-cluster/res/res_pjsip_publish_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-astdb-cluster/res/res_pjsip_publish_asterisk.c?view=diff&rev=433716&r1=433715&r2=433716
==============================================================================
--- team/mjordan/trunk-astdb-cluster/res/res_pjsip_publish_asterisk.c (original)
+++ team/mjordan/trunk-astdb-cluster/res/res_pjsip_publish_asterisk.c Sat Mar 28 11:18:22 2015
@@ -1258,10 +1258,31 @@
 	&asterisk_db_publisher_handler,
 };
 
+static int unload_module(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_LEN(publish_handlers); i++) {
+		ast_sip_unregister_publish_handler(publish_handlers[i]);
+	}
+
+	for (i = 0; i < ARRAY_LEN(event_publisher_handlers); i++) {
+		ast_sip_unregister_event_publisher_handler(event_publisher_handlers[i]);
+	}
+
+	return 0;
+}
+
+static int reload_module(void)
+{
+	ast_sorcery_reload_object(ast_sip_get_sorcery(), "asterisk-publication");
+	asterisk_publication_send_refresh();
+	return 0;
+}
+
 static int load_module(void)
 {
 	int i;
-	int j;
 
 	CHECK_PJSIP_PUBSUB_MODULE_LOADED();
 
@@ -1288,9 +1309,7 @@
 		if (ast_sip_register_publish_handler(publish_handlers[i])) {
 			ast_log(LOG_WARNING, "Unable to register event publication handler %s\n",
 				publish_handlers[i]->event_name);
-			for (j = 0; j < i; j++) {
-				ast_sip_unregister_publish_handler(publish_handlers[j]);
-			}
+			unload_module();
 			return AST_MODULE_LOAD_DECLINE;
 		}
 	}
@@ -1299,12 +1318,7 @@
 		if (ast_sip_register_event_publisher_handler(event_publisher_handlers[i])) {
 			ast_log(LOG_WARNING, "Unable to register event publisher handler %s\n",
 				event_publisher_handlers[i]->event_name);
-			for (j = 0; j < ARRAY_LEN(&publish_handlers); j++) {
-				ast_sip_unregister_publish_handler(publish_handlers[j]);
-			}
-			for (j = 0; j < i; j++) {
-				ast_sip_unregister_event_publisher_handler(event_publisher_handlers[j]);
-			}
+			unload_module();
 			return AST_MODULE_LOAD_DECLINE;
 		}
 	}
@@ -1312,28 +1326,6 @@
 	asterisk_publication_send_refresh();
 
 	return AST_MODULE_LOAD_SUCCESS;
-}
-
-static int reload_module(void)
-{
-	ast_sorcery_reload_object(ast_sip_get_sorcery(), "asterisk-publication");
-	asterisk_publication_send_refresh();
-	return 0;
-}
-
-static int unload_module(void)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_LEN(publish_handlers); i++) {
-		ast_sip_unregister_publish_handler(publish_handlers[i]);
-	}
-
-	for (i = 0; i < ARRAY_LEN(event_publisher_handlers); i++) {
-		ast_sip_unregister_event_publisher_handler(event_publisher_handlers[i]);
-	}
-
-	return 0;
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Asterisk Event PUBLISH Support",




More information about the asterisk-commits mailing list