[asterisk-commits] russell: branch russell/events r85538 - in /team/russell/events/res: ./ ais/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Oct 13 22:54:17 CDT 2007
Author: russell
Date: Sat Oct 13 22:54:16 2007
New Revision: 85538
URL: http://svn.digium.com/view/asterisk?view=rev&rev=85538
Log:
* Fix a typo in res/Makefile
* Add the initial stuff for the CKPT service and the AMF
- the initialization and shutdown stuff for module load and unload
- add each to the dispatch thread for running callbacks
Added:
team/russell/events/res/ais/amf.c (with props)
team/russell/events/res/ais/ckpt.c (with props)
Modified:
team/russell/events/res/Makefile
team/russell/events/res/ais/ais.h
team/russell/events/res/res_ais.c
Modified: team/russell/events/res/Makefile
URL: http://svn.digium.com/view/asterisk/team/russell/events/res/Makefile?view=diff&rev=85538&r1=85537&r2=85538
==============================================================================
--- team/russell/events/res/Makefile (original)
+++ team/russell/events/res/Makefile Sat Oct 13 22:54:16 2007
@@ -31,7 +31,7 @@
ael/ael.tab.o: ael/ael.tab.c ael/ael.tab.h ../include/asterisk/ael_structs.h
ael/ael.tab.o: ASTCFLAGS+=-I. -Iael -DYYENABLE_NLS=0
-$(if $(filter res_snmp,$(EMBEDDED_MODS)),modules.link,res_ais.so): ais/clm.o ais/evt.o ais/lck.o
+$(if $(filter res_ais,$(EMBEDDED_MODS)),modules.link,res_ais.so): ais/amf.o ais/clm.o ais/evt.o ais/lck.o ais/ckpt.o
$(if $(filter res_snmp,$(EMBEDDED_MODS)),modules.link,res_snmp.so): snmp/agent.o
Modified: team/russell/events/res/ais/ais.h
URL: http://svn.digium.com/view/asterisk/team/russell/events/res/ais/ais.h?view=diff&rev=85538&r1=85537&r2=85538
==============================================================================
--- team/russell/events/res/ais/ais.h (original)
+++ team/russell/events/res/ais/ais.h Sat Oct 13 22:54:16 2007
@@ -22,22 +22,32 @@
*
* \brief Usage of the SAForum AIS (Application Interface Specification)
*
- * \arg http://developer.osdl.org/dev/openais/
+ * \arg http://www.openais.org/
*/
#ifndef AST_AIS_H
#define AST_AIS_H
#include <openais/saAis.h>
+#include <openais/saAmf.h>
+#include <openais/saCkpt.h>
#include <openais/saClm.h>
#include <openais/saEvt.h>
#include <openais/saLck.h>
extern SaVersionT ais_version;
-extern SaClmHandleT clm_handle;
-extern SaEvtHandleT evt_handle;
-extern SaLckHandleT lck_handle;
+extern SaAmfHandleT amf_handle;
+extern SaCkptHandleT ckpt_handle;
+extern SaClmHandleT clm_handle;
+extern SaEvtHandleT evt_handle;
+extern SaLckHandleT lck_handle;
+
+int ast_ais_amf_load_module(void);
+int ast_ais_amf_unload_module(void);
+
+int ast_ais_ckpt_load_module(void);
+int ast_ais_ckpt_unload_module(void);
int ast_ais_clm_load_module(void);
int ast_ais_clm_unload_module(void);
Added: team/russell/events/res/ais/amf.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/res/ais/amf.c?view=auto&rev=85538
==============================================================================
--- team/russell/events/res/ais/amf.c (added)
+++ team/russell/events/res/ais/amf.c Sat Oct 13 22:54:16 2007
@@ -1,0 +1,89 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2007, Digium, Inc.
+ *
+ * Russell Bryant <russell at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \author Russell Bryant <russell at digium.com>
+ *
+ * \brief Usage of the SAForum AIS (Application Interface Specification)
+ *
+ * \arg http://www.openais.org/
+ *
+ * This file contains the code specific to the use of the AMF (Application
+ * Management Framework).
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "ais.h"
+
+#include "asterisk/module.h"
+#include "asterisk/utils.h"
+#include "asterisk/cli.h"
+#include "asterisk/logger.h"
+
+SaAmfHandleT amf_handle;
+
+static const SaAmfCallbacksT amf_callbacks = {
+ .saAmfHealthcheckCallback = NULL,
+ .saAmfComponentTerminateCallback = NULL,
+ .saAmfCSISetCallback = NULL,
+ .saAmfProtectionGroupTrackCallback = NULL,
+#if 0
+ /*! XXX \todo These appear to be define in the B.02.01 spec, but this won't
+ * compile with them in there. Look into it some more ... */
+ .saAmfProxiedComponentInstantiateCallback = NULL,
+ .saAmfProxiedComponentCleanupCallback = NULL,
+#endif
+};
+
+int ast_ais_amf_load_module(void)
+{
+ SaAisErrorT ais_res;
+
+ ais_res = saAmfInitialize(&amf_handle, &amf_callbacks, &ais_version);
+ if (ais_res != SA_AIS_OK) {
+ ast_log(LOG_ERROR, "Could not initialize AMF: %s\n",
+ ais_err2str(ais_res));
+ return -1;
+ }
+
+ return 0;
+}
+
+int ast_ais_amf_unload_module(void)
+{
+ SaAisErrorT ais_res;
+
+ ais_res = saAmfFinalize(amf_handle);
+ if (ais_res != SA_AIS_OK) {
+ ast_log(LOG_ERROR, "Problem stopping AMF: %s\n",
+ ais_err2str(ais_res));
+ return -1;
+ }
+
+ return 0;
+}
Propchange: team/russell/events/res/ais/amf.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/russell/events/res/ais/amf.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/russell/events/res/ais/amf.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/russell/events/res/ais/ckpt.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/res/ais/ckpt.c?view=auto&rev=85538
==============================================================================
--- team/russell/events/res/ais/ckpt.c (added)
+++ team/russell/events/res/ais/ckpt.c Sat Oct 13 22:54:16 2007
@@ -1,0 +1,78 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2007, Digium, Inc.
+ *
+ * Russell Bryant <russell at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \author Russell Bryant <russell at digium.com>
+ *
+ * \brief Usage of the SAForum AIS (Application Interface Specification)
+ *
+ * \arg http://www.openais.org/
+ *
+ * This file contains the code specific to the use of the CKPT (Checkpoint)
+ * service.
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "ais.h"
+
+#include "asterisk/module.h"
+#include "asterisk/utils.h"
+#include "asterisk/cli.h"
+#include "asterisk/logger.h"
+
+SaCkptHandleT ckpt_handle;
+
+static const SaCkptCallbacksT ckpt_callbacks;
+
+int ast_ais_ckpt_load_module(void)
+{
+ SaAisErrorT ais_res;
+
+ ais_res = saCkptInitialize(&ckpt_handle, &ckpt_callbacks, &ais_version);
+ if (ais_res != SA_AIS_OK) {
+ ast_log(LOG_ERROR, "Could not initialize CKPT service: %s\n",
+ ais_err2str(ais_res));
+ return -1;
+ }
+
+ return 0;
+}
+
+int ast_ais_ckpt_unload_module(void)
+{
+ SaAisErrorT ais_res;
+
+ ais_res = saCkptFinalize(amf_handle);
+ if (ais_res != SA_AIS_OK) {
+ ast_log(LOG_ERROR, "Problem stopping CKPT service: %s\n",
+ ais_err2str(ais_res));
+ return -1;
+ }
+
+ return 0;
+}
Propchange: team/russell/events/res/ais/ckpt.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/russell/events/res/ais/ckpt.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/russell/events/res/ais/ckpt.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: team/russell/events/res/res_ais.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/res/res_ais.c?view=diff&rev=85538&r1=85537&r2=85538
==============================================================================
--- team/russell/events/res/res_ais.c (original)
+++ team/russell/events/res/res_ais.c Sat Oct 13 22:54:16 2007
@@ -110,23 +110,39 @@
static void *dispatch_thread_handler(void *data)
{
- SaSelectionObjectT clm_fd, evt_fd, lck_fd, max_fd;
+ SaSelectionObjectT amf_fd, ckpt_fd, clm_fd, evt_fd, lck_fd, max_fd;
int res;
fd_set read_fds;
SaAisErrorT ais_res;
+ ais_res = saAmfSelectionObjectGet(amf_handle, &amf_fd);
+ if (ais_res != SA_AIS_OK) {
+ ast_log(LOG_ERROR, "Failed to retrieve select fd for AMF. "
+ "This module will not operate.\n");
+ return NULL;
+ }
+
+ ais_res = saCkptSelectionObjectGet(ckpt_handle, &ckpt_fd);
+ if (ais_res != SA_AIS_OK) {
+ ast_log(LOG_ERROR, "Failed to retrieve select fd for CKPT service. "
+ "This module will not operate.\n");
+ return NULL;
+ }
+
ais_res = saClmSelectionObjectGet(clm_handle, &clm_fd);
if (ais_res != SA_AIS_OK) {
ast_log(LOG_ERROR, "Failed to retrieve select fd for CLM service. "
"This module will not operate.\n");
return NULL;
}
+
ais_res = saEvtSelectionObjectGet(evt_handle, &evt_fd);
if (ais_res != SA_AIS_OK) {
ast_log(LOG_ERROR, "Failed to retrieve select fd for EVT service. "
"This module will not operate.\n");
return NULL;
}
+
ais_res = saLckSelectionObjectGet(lck_handle, &lck_fd);
if (ais_res != SA_AIS_OK) {
ast_log(LOG_ERROR, "Failed to retrieve select fd for LCK service. "
@@ -135,26 +151,38 @@
}
max_fd = clm_fd > evt_fd ? clm_fd : evt_fd;
+ if (ckpt_fd > max_fd)
+ max_fd = ckpt_fd;
if (lck_fd > max_fd)
max_fd = lck_fd;
+ if (amf_fd > max_fd)
+ max_fd = amf_fd;
while (!dispatch_thread.stop) {
FD_ZERO(&read_fds);
- FD_SET(clm_fd, &read_fds);
- FD_SET(evt_fd, &read_fds);
- FD_SET(lck_fd, &read_fds);
+ FD_SET(amf_fd, &read_fds);
+ FD_SET(ckpt_fd, &read_fds);
+ FD_SET(clm_fd, &read_fds);
+ FD_SET(evt_fd, &read_fds);
+ FD_SET(lck_fd, &read_fds);
+
res = ast_select(max_fd + 1, &read_fds, NULL, NULL, NULL);
if (res == -1 && errno != EINTR && errno != EAGAIN) {
ast_log(LOG_ERROR, "Select error (%s) dispatch thread going away now, "
"and the module will no longer operate.\n", strerror(errno));
break;
}
- if (FD_ISSET(clm_fd, &read_fds))
- saClmDispatch(clm_handle, SA_DISPATCH_ALL);
- if (FD_ISSET(evt_fd, &read_fds))
- saEvtDispatch(evt_handle, SA_DISPATCH_ALL);
- if (FD_ISSET(lck_fd, &read_fds))
- saLckDispatch(lck_handle, SA_DISPATCH_ALL);
+
+ if (FD_ISSET(amf_fd, &read_fds))
+ saAmfDispatch(amf_handle, SA_DISPATCH_ALL);
+ if (FD_ISSET(ckpt_fd, &read_fds))
+ saCkptDispatch(ckpt_handle, SA_DISPATCH_ALL);
+ if (FD_ISSET(clm_fd, &read_fds))
+ saClmDispatch(clm_handle, SA_DISPATCH_ALL);
+ if (FD_ISSET(evt_fd, &read_fds))
+ saEvtDispatch(evt_handle, SA_DISPATCH_ALL);
+ if (FD_ISSET(lck_fd, &read_fds))
+ saLckDispatch(lck_handle, SA_DISPATCH_ALL);
}
return NULL;
@@ -162,6 +190,12 @@
static int load_module(void)
{
+ if (ast_ais_amf_load_module())
+ goto amf_failed;
+
+ if (ast_ais_ckpt_load_module())
+ goto ckpt_failed;
+
if (ast_ais_clm_load_module())
goto clm_failed;
@@ -171,21 +205,32 @@
if (ast_ais_lck_load_module())
goto lck_failed;
- ast_pthread_create_background(&dispatch_thread.id, NULL,
- dispatch_thread_handler, NULL);
+ if (ast_pthread_create_background(&dispatch_thread.id, NULL,
+ dispatch_thread_handler, NULL)) {
+ ast_log(LOG_ERROR, "Error starting AIS dispatch thread.\n");
+ goto dispatch_failed;
+ }
return AST_MODULE_LOAD_SUCCESS;
+dispatch_failed:
+ ast_ais_lck_unload_module();
lck_failed:
ast_ais_evt_unload_module();
evt_failed:
ast_ais_clm_unload_module();
clm_failed:
+ ast_ais_ckpt_unload_module();
+ckpt_failed:
+ ast_ais_amf_unload_module();
+amf_failed:
return AST_MODULE_LOAD_DECLINE;
}
static int unload_module(void)
{
+ ast_ais_amf_unload_module();
+ ast_ais_ckpt_unload_module();
ast_ais_clm_unload_module();
ast_ais_evt_unload_module();
ast_ais_lck_unload_module();
More information about the asterisk-commits
mailing list