From dc5d68afba1c20dd0022b715b9818621dc047297 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Thu, 12 Jul 2012 13:09:22 -0600 Subject: [PATCH] dtsession: don't exit while processing your own session exit event. Setup a global that protects against accidentally exiting while doing session exit related housekeeping. --- cde/programs/dtsession/Sm.h | 3 +++ cde/programs/dtsession/SmGlobals.c | 19 +++++++++++++------ cde/programs/dtsession/SmMain.c | 3 +++ cde/programs/dtsession/SmUI.c | 12 ++++++++++++ 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/cde/programs/dtsession/Sm.h b/cde/programs/dtsession/Sm.h index 726f7afb..cd548334 100644 --- a/cde/programs/dtsession/Sm.h +++ b/cde/programs/dtsession/Sm.h @@ -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; diff --git a/cde/programs/dtsession/SmGlobals.c b/cde/programs/dtsession/SmGlobals.c index 2a809ee6..36c35119 100644 --- a/cde/programs/dtsession/SmGlobals.c +++ b/cde/programs/dtsession/SmGlobals.c @@ -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 diff --git a/cde/programs/dtsession/SmMain.c b/cde/programs/dtsession/SmMain.c index 638d7605..52a8ca9a 100644 --- a/cde/programs/dtsession/SmMain.c +++ b/cde/programs/dtsession/SmMain.c @@ -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 diff --git a/cde/programs/dtsession/SmUI.c b/cde/programs/dtsession/SmUI.c index 243996d0..1c7a6d0f 100644 --- a/cde/programs/dtsession/SmUI.c +++ b/cde/programs/dtsession/SmUI.c @@ -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) { /* -- 2.25.1