* at the top of the source tree.
*/
-/*!
+/*!
* \file
* \author Russell Bryant <russell@digium.com>
*
*
* \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.
*/
#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);
.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)
{
"=== ==> 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");
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;
}
{
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;
}
* at the top of the source tree.
*/
-/*!
+/*!
* \file
* \author Russell Bryant <russell@digium.com>
*
*
* \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.
*/
#endif
SaEvtHandleT evt_handle;
+static SaAisErrorT evt_init_res;
void evt_channel_open_cb(SaInvocationT invocation, SaEvtChannelHandleT channel_handle,
SaAisErrorT error);
static const SaEvtCallbacksT evt_callbacks = {
.saEvtChannelOpenCallback = evt_channel_open_cb,
- .saEvtEventDeliverCallback = evt_event_deliver_cb,
+ .saEvtEventDeliverCallback = evt_event_deliver_cb,
};
static const struct {
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;
}
if (!(event_dup = ast_malloc(len)))
return;
-
+
memcpy(event_dup, event, len);
queue_event(event_dup);
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));
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,
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));
"=== 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));
}
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;
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) {
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);
}
}
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;
}
-
+
load_config();
ast_cli_register_multiple(ais_cli, ARRAY_LEN(ais_cli));
{
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",
+ ast_log(LOG_ERROR, "Problem stopping eventing service: %s\n",
ais_err2str(ais_res));
return -1;
}
- return 0;
+ return 0;
}