dtsession: don't exit while processing your own session exit event.
authorJon Trulson <jon@radscan.com>
Thu, 12 Jul 2012 19:09:22 +0000 (13:09 -0600)
committerJon Trulson <jon@radscan.com>
Thu, 12 Jul 2012 19:09:22 +0000 (13:09 -0600)
Setup a global that protects against accidentally exiting
while doing session exit related housekeeping.

cde/programs/dtsession/Sm.h
cde/programs/dtsession/SmGlobals.c
cde/programs/dtsession/SmMain.c
cde/programs/dtsession/SmUI.c

index 726f7afb4bf8bc49148cf2da01399f65e88acbf8..cd5483348ff449307dff67fa0e2914917397a8b4 100644 (file)
@@ -336,6 +336,9 @@ typedef struct
                                    specific display, otherwise False */
     Boolean    loggingOut;     /* Is True if the current save is for
                                   a logout; False otherwise. */
+
+    Boolean ExitComplete;      /* JET - don't exit before we are ready... */
+
 } GeneralData;
 
 
index 2a809ee62664bfc42c8fcb7b1952ff8a1c8ea7f6..36c351197d55a539a336a687278381ff78da5330 100644 (file)
@@ -2564,12 +2564,19 @@ void
 SmExit (
        int             exitStatus)
 {
-       if (smXSMP.saveState.saveComplete && 
-           smXSMP.saveState.shutdown &&
-           !smXSMP.saveState.shutdownCanceled)
-               XSMPExit ();
-
-       exit (exitStatus);
+  /* JET - needed to rework this to avoid exiting before we are
+   *  *really* ready to 
+   */
+  if (smGD.ExitComplete)
+    {
+      if (smXSMP.saveState.saveComplete && 
+         smXSMP.saveState.shutdown &&
+         !smXSMP.saveState.shutdownCanceled)
+       XSMPExit ();
+      exit(exitStatus);
+    }
+  else
+    return;
 }
 
 void
index 638d7605a00315b7736b407ea3c18d0fecfd8d4b..52a8ca9a3744307b3e7c96377592e050295de48f 100644 (file)
@@ -171,6 +171,9 @@ main (int argc,
     smGD.smState = IN_PROCESS;
     smGD.programName = strdup (argv[0]);
 
+    /* JET - By default, we always want to leave when SmExit() is called. */
+    smGD.ExitComplete = True;
+
     /*
      * We report some errors before we call the DtInitialize procedure.
      * The Dt initialize procedure sets this name.  If we report
index 243996d01a22a36b3694b49028db4b9059c8dc57..1c7a6d0fa95a20d44642b6444ca53113c1e5f024 100644 (file)
@@ -1208,6 +1208,11 @@ ImmediateExit(
 
        smGD.loggingOut = True;
 
+        /* JET - set this here so we don't exit prematurely (while
+         * handling our own SM exit callback - duh).
+         */
+       smGD.ExitComplete = False;
+
         saveTimeout = False;
        timerId = XtAppAddTimeOut (smGD.appCon, smRes.saveYourselfTimeout, 
                                   SaveTimeout, NULL);
@@ -1221,6 +1226,13 @@ ImmediateExit(
                XtDispatchEvent(&next);
        }
     }
+    
+    /* JET - need this, since dtsession was exiting in the
+     * XtAppNextEvent above (receiving it's own EXIT SM message) This
+     * is checked in SmExit() so exit's will only occur after this
+     * housekeeping has been completed.
+     */
+    smGD.ExitComplete = True; 
 
     if (smXSMP.saveState.shutdownCanceled == False) {
        /*