mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-19 16:20:37 +00:00
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
This commit is contained in:
@@ -46,6 +46,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
|
|||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
|
|
||||||
SaClmHandleT clm_handle;
|
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);
|
const SaClmClusterNodeT *cluster_node, SaAisErrorT error);
|
||||||
@@ -134,12 +135,10 @@ static struct ast_cli_entry ais_cli[] = {
|
|||||||
|
|
||||||
int ast_ais_clm_load_module(void)
|
int ast_ais_clm_load_module(void)
|
||||||
{
|
{
|
||||||
SaAisErrorT ais_res;
|
clm_init_res = saClmInitialize(&clm_handle, &clm_callbacks, &ais_version);
|
||||||
|
if (clm_init_res != SA_AIS_OK) {
|
||||||
ais_res = saClmInitialize(&clm_handle, &clm_callbacks, &ais_version);
|
|
||||||
if (ais_res != SA_AIS_OK) {
|
|
||||||
ast_log(LOG_ERROR, "Could not initialize cluster membership service: %s\n",
|
ast_log(LOG_ERROR, "Could not initialize cluster membership service: %s\n",
|
||||||
ais_err2str(ais_res));
|
ais_err2str(clm_init_res));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +151,10 @@ int ast_ais_clm_unload_module(void)
|
|||||||
{
|
{
|
||||||
SaAisErrorT ais_res;
|
SaAisErrorT ais_res;
|
||||||
|
|
||||||
|
if (clm_init_res != SA_AIS_OK) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ast_cli_unregister_multiple(ais_cli, ARRAY_LEN(ais_cli));
|
ast_cli_unregister_multiple(ais_cli, ARRAY_LEN(ais_cli));
|
||||||
|
|
||||||
ais_res = saClmFinalize(clm_handle);
|
ais_res = saClmFinalize(clm_handle);
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
SaEvtHandleT evt_handle;
|
SaEvtHandleT evt_handle;
|
||||||
|
static SaAisErrorT evt_init_res;
|
||||||
|
|
||||||
void evt_channel_open_cb(SaInvocationT invocation, SaEvtChannelHandleT channel_handle,
|
void evt_channel_open_cb(SaInvocationT invocation, SaEvtChannelHandleT channel_handle,
|
||||||
SaAisErrorT error);
|
SaAisErrorT error);
|
||||||
@@ -532,19 +533,18 @@ static void destroy_event_channels(void)
|
|||||||
struct event_channel *event_channel;
|
struct event_channel *event_channel;
|
||||||
|
|
||||||
AST_RWLIST_WRLOCK(&event_channels);
|
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);
|
event_channel_destroy(event_channel);
|
||||||
|
}
|
||||||
AST_RWLIST_UNLOCK(&event_channels);
|
AST_RWLIST_UNLOCK(&event_channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_ais_evt_load_module(void)
|
int ast_ais_evt_load_module(void)
|
||||||
{
|
{
|
||||||
SaAisErrorT ais_res;
|
evt_init_res = saEvtInitialize(&evt_handle, &evt_callbacks, &ais_version);
|
||||||
|
if (evt_init_res != SA_AIS_OK) {
|
||||||
ais_res = saEvtInitialize(&evt_handle, &evt_callbacks, &ais_version);
|
|
||||||
if (ais_res != SA_AIS_OK) {
|
|
||||||
ast_log(LOG_ERROR, "Could not initialize eventing service: %s\n",
|
ast_log(LOG_ERROR, "Could not initialize eventing service: %s\n",
|
||||||
ais_err2str(ais_res));
|
ais_err2str(evt_init_res));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,6 +559,10 @@ int ast_ais_evt_unload_module(void)
|
|||||||
{
|
{
|
||||||
SaAisErrorT ais_res;
|
SaAisErrorT ais_res;
|
||||||
|
|
||||||
|
if (evt_init_res != SA_AIS_OK) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
destroy_event_channels();
|
destroy_event_channels();
|
||||||
|
|
||||||
ais_res = saEvtFinalize(evt_handle);
|
ais_res = saEvtFinalize(evt_handle);
|
||||||
|
|||||||
Reference in New Issue
Block a user