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.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@271867 65c4cc65-6c06-0410-ace0-fbb531ad65f3
certified/1.8.6
Russell Bryant 16 years ago
parent 9cc7c55578
commit 294c78a27e

@ -46,6 +46,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
#include "asterisk/logger.h"
SaClmHandleT clm_handle;
static SaAisErrorT clm_init_res;
static void clm_node_get_cb(SaInvocationT invocation,
const SaClmClusterNodeT *cluster_node, SaAisErrorT error);
@ -134,12 +135,10 @@ static struct ast_cli_entry ais_cli[] = {
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,6 +151,10 @@ int ast_ais_clm_unload_module(void)
{
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);

@ -55,6 +55,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
#endif
SaEvtHandleT evt_handle;
static SaAisErrorT evt_init_res;
void evt_channel_open_cb(SaInvocationT invocation, SaEvtChannelHandleT channel_handle,
SaAisErrorT error);
@ -532,19 +533,18 @@ static void destroy_event_channels(void)
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(ais_res));
ais_err2str(evt_init_res));
return -1;
}
@ -559,6 +559,10 @@ 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);

Loading…
Cancel
Save