osaf/libs/common/edsv/include/eds.h   |   2 ++
 osaf/services/saf/edsv/eds/eds_cb.c   |  33 ++++++++++++++++++++++++---------
 osaf/services/saf/edsv/eds/eds_main.c |   1 -
 3 files changed, 26 insertions(+), 10 deletions(-)


All core services and cpsv now register for a common sigterm handler.
This patch series takes a stab at the optional services

diff --git a/osaf/libs/common/edsv/include/eds.h 
b/osaf/libs/common/edsv/include/eds.h
--- a/osaf/libs/common/edsv/include/eds.h
+++ b/osaf/libs/common/edsv/include/eds.h
@@ -69,6 +69,8 @@
 
 #include "ncssysf_def.h"
 
+#include <daemon.h>
+
 /* EDS CB global handle declaration */
 uint32_t gl_eds_hdl;
 
diff --git a/osaf/services/saf/edsv/eds/eds_cb.c 
b/osaf/services/saf/edsv/eds/eds_cb.c
--- a/osaf/services/saf/edsv/eds/eds_cb.c
+++ b/osaf/services/saf/edsv/eds/eds_cb.c
@@ -32,14 +32,18 @@ This contains the EDS_CB functions.
 #include "signal.h"
 #include "logtrace.h"
 
-#define FD_AMF 0
-#define FD_MBCSV 1
-#define FD_MBX 2
-#define FD_CLM 3
-#define FD_IMM 4               /* Must be the last in the fds array */
+enum {
+       FD_TERM = 0,
+       FD_AMF,
+       FD_MBCSV,
+       FD_MBX,
+       FD_CLM,
+       FD_IMM,
+       NUM_FD
+};
 
-static struct pollfd fds[5];
-static nfds_t nfds = 5;
+static struct pollfd fds[6];
+static nfds_t nfds = 6;
 
 
 /****************************************************************************
@@ -177,6 +181,7 @@ void eds_main_process(SYSF_MBX *mbx)
        NCS_SEL_OBJ mbx_fd;
        SaAisErrorT error = SA_AIS_OK;
        EDS_CB *eds_cb = NULL;
+       int term_fd;
        TRACE_ENTER();
 
        if (NULL == (eds_cb = (EDS_CB *)ncshm_take_hdl(NCS_SERVICE_ID_EDS, 
gl_eds_hdl))) {
@@ -195,7 +200,11 @@ void eds_main_process(SYSF_MBX *mbx)
                exit(EXIT_FAILURE);
        }
 
+       daemon_sigterm_install(&term_fd);
+
        /* Set up all file descriptors to listen to */
+       fds[FD_TERM].fd = term_fd;
+       fds[FD_TERM].events = POLLIN;
        fds[FD_AMF].fd = eds_cb->amfSelectionObject;
        fds[FD_AMF].events = POLLIN;
        fds[FD_CLM].fd = eds_cb->clm_sel_obj;
@@ -214,9 +223,9 @@ void eds_main_process(SYSF_MBX *mbx)
                if ((eds_cb->immOiHandle != 0) && (eds_cb->is_impl_set == 
true)){
                        fds[FD_IMM].fd = eds_cb->imm_sel_obj;
                        fds[FD_IMM].events = POLLIN;
-                       nfds = FD_IMM + 1;
+                       nfds = NUM_FD;
                } else {
-                       nfds = FD_IMM;
+                       nfds = NUM_FD - 1;
                }
                
                int ret = poll(fds, nfds, -1);
@@ -228,6 +237,12 @@ void eds_main_process(SYSF_MBX *mbx)
                        TRACE("poll failed - %s", strerror(errno));
                        break;
                }
+
+               /* process the sigterm */
+               if (fds[FD_TERM].revents & POLLIN) {
+                       daemon_exit();
+               }
+
                /* process all the AMF messages */
                if (fds[FD_AMF].revents & POLLIN) {
                        /* dispatch all the AMF pending callbacks */
diff --git a/osaf/services/saf/edsv/eds/eds_main.c 
b/osaf/services/saf/edsv/eds/eds_main.c
--- a/osaf/services/saf/edsv/eds/eds_main.c
+++ b/osaf/services/saf/edsv/eds/eds_main.c
@@ -17,7 +17,6 @@
 
 #include <ncssysf_tsk.h>
 #include <logtrace.h>
-#include <daemon.h>
 
 #include "eds.h"
 

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to