[svn-commits] russell: branch 1.6.2 r271869 - in /branches/1.6.2: ./ res/ais/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jun 22 11:30:34 CDT 2010


Author: russell
Date: Tue Jun 22 11:30:30 2010
New Revision: 271869

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=271869
Log:
Merged revisions 271867 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r271867 | russell | 2010-06-22 11:28:03 -0500 (Tue, 22 Jun 2010) | 7 lines
  
  Resolve some errors that occur on a graceful shutdown.
  
  Don't Finalize() if Initialize() did not succeed.  This resulted in an error
  about trying to Finalize() an invalid handle.
  
  Also trim some trailing whitespace while in the area.
........

Modified:
    branches/1.6.2/   (props changed)
    branches/1.6.2/res/ais/clm.c
    branches/1.6.2/res/ais/evt.c

Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.2/res/ais/clm.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/res/ais/clm.c?view=diff&rev=271869&r1=271868&r2=271869
==============================================================================
--- branches/1.6.2/res/ais/clm.c (original)
+++ branches/1.6.2/res/ais/clm.c Tue Jun 22 11:30:30 2010
@@ -16,7 +16,7 @@
  * at the top of the source tree.
  */
 
-/*! 
+/*!
  * \file
  * \author Russell Bryant <russell at digium.com>
  *
@@ -24,7 +24,7 @@
  *
  * \arg http://www.openais.org/
  *
- * This file contains the code specific to the use of the CLM 
+ * This file contains the code specific to the use of the CLM
  * (Cluster Membership) Service.
  */
 
@@ -46,8 +46,9 @@
 #include "asterisk/logger.h"
 
 SaClmHandleT clm_handle;
+static SaAisErrorT clm_init_res;
 
-static void clm_node_get_cb(SaInvocationT invocation, 
+static void clm_node_get_cb(SaInvocationT invocation,
 	const SaClmClusterNodeT *cluster_node, SaAisErrorT error);
 static void clm_track_cb(const SaClmClusterNotificationBufferT *notif_buffer,
 	SaUint32T num_members, SaAisErrorT error);
@@ -57,7 +58,7 @@
 	.saClmClusterTrackCallback   = clm_track_cb,
 };
 
-static void clm_node_get_cb(SaInvocationT invocation, 
+static void clm_node_get_cb(SaInvocationT invocation,
 	const SaClmClusterNodeT *cluster_node, SaAisErrorT error)
 {
 
@@ -114,7 +115,7 @@
 		               "=== ==> ID: 0x%x\n"
 		               "=== ==> Address: %s\n"
 		               "=== ==> Member: %s\n",
-		               (char *) node->nodeName.value, (int) node->nodeId, 
+		               (char *) node->nodeName.value, (int) node->nodeId,
 		               (char *) node->nodeAddress.value,
 		               node->member ? "Yes" : "No");
 
@@ -134,12 +135,10 @@
 
 int ast_ais_clm_load_module(void)
 {
-	SaAisErrorT ais_res;
-
-	ais_res = saClmInitialize(&clm_handle, &clm_callbacks, &ais_version);
-	if (ais_res != SA_AIS_OK) {
+	clm_init_res = saClmInitialize(&clm_handle, &clm_callbacks, &ais_version);
+	if (clm_init_res != SA_AIS_OK) {
 		ast_log(LOG_ERROR, "Could not initialize cluster membership service: %s\n",
-			ais_err2str(ais_res));
+			ais_err2str(clm_init_res));
 		return -1;
 	}
 
@@ -152,11 +151,15 @@
 {
 	SaAisErrorT ais_res;
 
+	if (clm_init_res != SA_AIS_OK) {
+		return 0;
+	}
+
 	ast_cli_unregister_multiple(ais_cli, ARRAY_LEN(ais_cli));
 
 	ais_res = saClmFinalize(clm_handle);
 	if (ais_res != SA_AIS_OK) {
-		ast_log(LOG_ERROR, "Problem stopping cluster membership service: %s\n", 
+		ast_log(LOG_ERROR, "Problem stopping cluster membership service: %s\n",
 			ais_err2str(ais_res));
 		return -1;
 	}

Modified: branches/1.6.2/res/ais/evt.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/res/ais/evt.c?view=diff&rev=271869&r1=271868&r2=271869
==============================================================================
--- branches/1.6.2/res/ais/evt.c (original)
+++ branches/1.6.2/res/ais/evt.c Tue Jun 22 11:30:30 2010
@@ -16,7 +16,7 @@
  * at the top of the source tree.
  */
 
-/*! 
+/*!
  * \file
  * \author Russell Bryant <russell at digium.com>
  *
@@ -24,7 +24,7 @@
  *
  * \arg http://www.openais.org/
  *
- * This file contains the code specific to the use of the EVT 
+ * This file contains the code specific to the use of the EVT
  * (Event) Service.
  */
 
@@ -55,6 +55,7 @@
 #endif
 
 SaEvtHandleT evt_handle;
+static SaAisErrorT evt_init_res;
 
 void evt_channel_open_cb(SaInvocationT invocation, SaEvtChannelHandleT channel_handle,
 	SaAisErrorT error);
@@ -63,7 +64,7 @@
 
 static const SaEvtCallbacksT evt_callbacks = {
 	.saEvtChannelOpenCallback  = evt_channel_open_cb,
-	.saEvtEventDeliverCallback = evt_event_deliver_cb, 
+	.saEvtEventDeliverCallback = evt_event_deliver_cb,
 };
 
 static const struct {
@@ -136,7 +137,7 @@
 
 	ais_res = saEvtEventDataGet(event_handle, event, &len);
 	if (ais_res != SA_AIS_OK) {
-		ast_log(LOG_ERROR, "Error retrieving event payload: %s\n", 
+		ast_log(LOG_ERROR, "Error retrieving event payload: %s\n",
 			ais_err2str(ais_res));
 		return;
 	}
@@ -148,7 +149,7 @@
 
 	if (!(event_dup = ast_malloc(len)))
 		return;
-	
+
 	memcpy(event_dup, event, len);
 
 	queue_event(event_dup);
@@ -195,8 +196,8 @@
 		ast_log(LOG_DEBUG, "Returning here\n");
 		return;
 	}
-	
-	ais_res = saClmClusterNodeGet(clm_handle, SA_CLM_LOCAL_NODE_ID, 
+
+	ais_res = saClmClusterNodeGet(clm_handle, SA_CLM_LOCAL_NODE_ID,
 		SA_TIME_ONE_SECOND, &local_node);
 	if (ais_res != SA_AIS_OK) {
 		ast_log(LOG_ERROR, "Error getting local node name: %s\n", ais_err2str(ais_res));
@@ -213,8 +214,8 @@
 	pattern_array.patternsNumber = 1;
 	pattern_array.patterns = &pattern;
 
-	/*! 
-	 * /todo Make retention time configurable 
+	/*!
+	 * /todo Make retention time configurable
 	 * /todo Make event priorities configurable
 	 */
 	ais_res = saEvtEventAttributesSet(event_handle, &pattern_array,
@@ -224,7 +225,7 @@
 		goto return_event_free;
 	}
 
-	ais_res = saEvtEventPublish(event_handle, 
+	ais_res = saEvtEventPublish(event_handle,
 		ast_event, ast_event_get_size(ast_event), &event_id);
 	if (ais_res != SA_AIS_OK) {
 		ast_log(LOG_ERROR, "Error publishing event: %s\n", ais_err2str(ais_res));
@@ -273,12 +274,12 @@
 		               "=== Event Channel Name: %s\n", event_channel->name);
 
 		AST_LIST_TRAVERSE(&event_channel->publish_events, publish_event, entry) {
-			ast_cli(a->fd, "=== ==> Publishing Event Type: %s\n", 
+			ast_cli(a->fd, "=== ==> Publishing Event Type: %s\n",
 				type_to_filter_str(publish_event->type));
 		}
-		
+
 		AST_LIST_TRAVERSE(&event_channel->subscribe_events, subscribe_event, entry) {
-			ast_cli(a->fd, "=== ==> Subscribing to Event Type: %s\n", 
+			ast_cli(a->fd, "=== ==> Subscribing to Event Type: %s\n",
 				type_to_filter_str(subscribe_event->type));
 		}
 
@@ -353,7 +354,7 @@
 	filter_array.filtersNumber = 1;
 	filter_array.filters = &filter;
 
-	ais_res = saEvtEventSubscribe(event_channel->handle, &filter_array, 
+	ais_res = saEvtEventSubscribe(event_channel->handle, &filter_array,
 		subscribe_event->id);
 
 	return ais_res;
@@ -425,7 +426,7 @@
 	strcpy(event_channel->name, cat);
 	ast_copy_string((char *) sa_name.value, cat, sizeof(sa_name.value));
 	sa_name.length = strlen((char *) sa_name.value);
-	ais_res = saEvtChannelOpen(evt_handle, &sa_name, 
+	ais_res = saEvtChannelOpen(evt_handle, &sa_name,
 		SA_EVT_CHANNEL_PUBLISHER | SA_EVT_CHANNEL_SUBSCRIBER | SA_EVT_CHANNEL_CREATE,
 		SA_TIME_MAX, &event_channel->handle);
 	if (ais_res != SA_AIS_OK) {
@@ -477,7 +478,7 @@
 		if (!strcasecmp(type, "event_channel")) {
 			build_event_channel(cfg, cat);
 		} else {
-			ast_log(LOG_WARNING, "Entry in %s defined with invalid type '%s'\n", 
+			ast_log(LOG_WARNING, "Entry in %s defined with invalid type '%s'\n",
 				filename, type);
 		}
 	}
@@ -532,41 +533,44 @@
 	struct event_channel *event_channel;
 
 	AST_RWLIST_WRLOCK(&event_channels);
-	while ((event_channel = AST_RWLIST_REMOVE_HEAD(&event_channels, entry)))
+	while ((event_channel = AST_RWLIST_REMOVE_HEAD(&event_channels, entry))) {
 		event_channel_destroy(event_channel);
+	}
 	AST_RWLIST_UNLOCK(&event_channels);
 }
 
 int ast_ais_evt_load_module(void)
 {
-	SaAisErrorT ais_res;
-
-	ais_res = saEvtInitialize(&evt_handle, &evt_callbacks, &ais_version);
-	if (ais_res != SA_AIS_OK) {
+	evt_init_res = saEvtInitialize(&evt_handle, &evt_callbacks, &ais_version);
+	if (evt_init_res != SA_AIS_OK) {
 		ast_log(LOG_ERROR, "Could not initialize eventing service: %s\n",
+			ais_err2str(evt_init_res));
+		return -1;
+	}
+
+	load_config();
+
+	ast_cli_register_multiple(ais_cli, ARRAY_LEN(ais_cli));
+
+	return 0;
+}
+
+int ast_ais_evt_unload_module(void)
+{
+	SaAisErrorT ais_res;
+
+	if (evt_init_res != SA_AIS_OK) {
+		return 0;
+	}
+
+	destroy_event_channels();
+
+	ais_res = saEvtFinalize(evt_handle);
+	if (ais_res != SA_AIS_OK) {
+		ast_log(LOG_ERROR, "Problem stopping eventing service: %s\n",
 			ais_err2str(ais_res));
 		return -1;
 	}
-	
-	load_config();
-
-	ast_cli_register_multiple(ais_cli, ARRAY_LEN(ais_cli));
 
 	return 0;
 }
-
-int ast_ais_evt_unload_module(void)
-{
-	SaAisErrorT ais_res;
-
-	destroy_event_channels();
-
-	ais_res = saEvtFinalize(evt_handle);
-	if (ais_res != SA_AIS_OK) {
-		ast_log(LOG_ERROR, "Problem stopping eventing service: %s\n", 
-			ais_err2str(ais_res));
-		return -1;
-	}
-
-	return 0;	
-}




More information about the svn-commits mailing list