osaf/libs/common/glsv/include/glnd.h | 2 ++ osaf/services/saf/glsv/glnd/glnd_api.c | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 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/glsv/include/glnd.h b/osaf/libs/common/glsv/include/glnd.h --- a/osaf/libs/common/glsv/include/glnd.h +++ b/osaf/libs/common/glsv/include/glnd.h @@ -74,6 +74,8 @@ G_GLND_MEMFAIL(GLND_RESTART_RSC_LOCK_LIS #include "glnd_edu.h" #include "glsv_mem.h" +#include <daemon.h> + /* #include "cpsv_mem.h" #include "cpa_mem.h" diff --git a/osaf/services/saf/glsv/glnd/glnd_api.c b/osaf/services/saf/glsv/glnd/glnd_api.c --- a/osaf/services/saf/glsv/glnd/glnd_api.c +++ b/osaf/services/saf/glsv/glnd/glnd_api.c @@ -34,6 +34,7 @@ #include "osaf_poll.h" enum { + FD_TERM = 0, FD_AMF, FD_MBX }; @@ -193,7 +194,8 @@ void glnd_main_process(SYSF_MBX *mbx) SaSelectionObjectT amf_sel_obj; SaAisErrorT amf_error; - struct pollfd sel[2]; + struct pollfd sel[3]; + int term_fd; /* take the handle */ glnd_cb = (GLND_CB *)m_GLND_TAKE_GLND_CB; @@ -213,12 +215,21 @@ void glnd_main_process(SYSF_MBX *mbx) goto end; } + daemon_sigterm_install(&term_fd); + + sel[FD_TERM].fd = term_fd; + sel[FD_TERM].events = POLLIN; sel[FD_AMF].fd = amf_sel_obj; sel[FD_AMF].events = POLLIN; sel[FD_MBX].fd = m_GET_FD_FROM_SEL_OBJ(mbx_fd); sel[FD_MBX].events = POLLIN; - while (osaf_poll(&sel[0], 2, -1) > 0) { + while (osaf_poll(&sel[0], 3, -1) > 0) { + + if (sel[FD_TERM].revents & POLLIN) { + daemon_exit(); + } + if (((sel[FD_AMF].revents | sel[FD_MBX].revents) & (POLLERR | POLLHUP | POLLNVAL)) != 0) { LOG_ER("GLND poll() failure: %hd %hd", ------------------------------------------------------------------------------ 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 Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel