Hi Hung,

Reviewed the patch.
Ack from me.

Thanks,
Zoran

-----Original Message-----
From: Hung Nguyen [mailto:[email protected]] 
Sent: den 11 april 2017 14:08
To: Zoran Milinkovic <[email protected]>; 
[email protected]
Cc: [email protected]
Subject: [PATCH 1 of 1] imm: Use waitpid with WNOHANG to check for sync process 
and pbe process [#2420]

 src/imm/immnd/immnd_evt.c  |   7 ++-----
 src/imm/immnd/immnd_proc.c |  25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 5 deletions(-)


Use waitpid with WNOHANG to check for sync process and pbe process.
The processes are checked before resending the intro message.
The intro message is only sent when those processes exit.

diff --git a/src/imm/immnd/immnd_evt.c b/src/imm/immnd/immnd_evt.c
--- a/src/imm/immnd/immnd_evt.c
+++ b/src/imm/immnd/immnd_evt.c
@@ -12232,8 +12232,6 @@ static uint32_t immnd_evt_proc_mds_evt(I
                                        LOG_NO(
                                            "Force kill sync process and abort 
sync");
                                        kill(cb->syncPid, SIGKILL);
-                                       waitpid(cb->syncPid, NULL, 0);
-                                       cb->syncPid = 0;
 
                                        cb->mState = IMM_SERVER_READY;
                                        LOG_NO(
@@ -12293,13 +12291,12 @@ static uint32_t immnd_evt_proc_mds_evt(I
                        int status = 0;
                        if (waitpid(cb->pbePid, &status, WNOHANG) > 0) {
                                LOG_NO("PBE has terminated due to SC absence");
+                               cb->pbePid = 0;
                        } else {
                                LOG_WA(
                                    "SC were absent and PBE appears hung, 
sending SIGKILL");
                                kill(cb->pbePid, SIGKILL);
-                               waitpid(cb->pbePid, NULL, 0);
-                       }
-                       cb->pbePid = 0;
+                       }
                }
 
        } else if ((evt->info.mds_info.change == NCSMDS_UP) &&
diff --git a/src/imm/immnd/immnd_proc.c b/src/imm/immnd/immnd_proc.c
--- a/src/imm/immnd/immnd_proc.c
+++ b/src/imm/immnd/immnd_proc.c
@@ -493,6 +493,31 @@ uint32_t immnd_introduceMe(IMMND_CB *cb)
        char *mdirDup = NULL;
        memset(&send_evt, '\0', sizeof(IMMSV_EVT));
 
+       if (cb->mIntroduced == 2) {
+               /* Check for syncPid and pbePid, intro message will not be sent
+                * until they all exit */
+               if (cb->syncPid > 0) {
+                       int status = 0;
+                       if (waitpid(cb->syncPid, &status, WNOHANG) > 0) {
+                               cb->syncPid = 0;
+                       } else {
+                               LOG_WA("Sync process still doesn't exit, skip 
sending intro message");
+                               rc = NCSCC_RC_FAILURE;
+                               goto error;
+                       }
+               }
+               if (cb->pbePid > 0) {
+                       int status = 0;
+                       if (waitpid(cb->pbePid, &status, WNOHANG) > 0) {
+                               cb->pbePid = 0;
+                       } else {
+                               LOG_WA("PBE process still doesn't exit, skip 
sending intro message");
+                               rc = NCSCC_RC_FAILURE;
+                               goto error;
+                       }
+               }
+       }
+
        send_evt.type = IMMSV_EVT_TYPE_IMMD;
        send_evt.info.immd.type = IMMD_EVT_ND2D_INTRO;
        send_evt.info.immd.info.ctrl_msg.ndExecPid = cb->mMyPid;

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to