diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2015-04-08 15:27:25 -0500 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2015-04-14 02:27:25 +0200 |
commit | 0621ed70db1176471ce992b8eeb4d32d90f2f547 (patch) | |
tree | 619c39131574153080b05877a701bf5f5af2b75c /kdesktop/lockeng.cc | |
parent | 6dd6500446c3cd6e9ac0a4d980f596d8bb67d7d0 (diff) | |
download | tdebase-0621ed70db1176471ce992b8eeb4d32d90f2f547.tar.gz tdebase-0621ed70db1176471ce992b8eeb4d32d90f2f547.zip |
Eliminate usleep() loop during kdesktop startup
Do not switch desktops if lock fails to engage
(cherry picked from commit 751c96f9b1fc01675a1a9d34831104f98adfd84f)
Diffstat (limited to 'kdesktop/lockeng.cc')
-rw-r--r-- | kdesktop/lockeng.cc | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/kdesktop/lockeng.cc b/kdesktop/lockeng.cc index d4c46ed1b..8e59b9e72 100644 --- a/kdesktop/lockeng.cc +++ b/kdesktop/lockeng.cc @@ -415,13 +415,9 @@ bool SaverEngine::restartDesktopLockProcess() return false; } // Wait for the saver process to signal ready... - int count = 0; - while (!mSaverProcessReady) { - count++; - usleep(100); - if (count > 100) { - return false; - } + if (!waitForLockProcessStart()) { + kdDebug( 1204 ) << "Failed to initialize kdesktop_lock (unexpected termination)!" << endl; + return false; } } return true; @@ -797,7 +793,27 @@ void SaverEngine::handleDBusSignal(const TQT_DBusMessage& msg) { } } -void SaverEngine::waitForLockEngage() { +bool SaverEngine::waitForLockProcessStart() { + sigset_t new_mask; + sigset_t orig_mask; + + // wait for SIGUSR1, SIGUSR2, SIGTTIN, SIGCHLD + sigemptyset(&new_mask); + sigaddset(&new_mask, SIGUSR1); + sigaddset(&new_mask, SIGUSR2); + sigaddset(&new_mask, SIGTTIN); + sigaddset(&new_mask, SIGCHLD); + + sigprocmask(SIG_BLOCK, &new_mask, &orig_mask); + while ((mLockProcess.isRunning()) && (!mSaverProcessReady)) { + sigsuspend(&orig_mask); + } + sigprocmask(SIG_UNBLOCK, &new_mask, NULL); + + return mLockProcess.isRunning(); +} + +bool SaverEngine::waitForLockEngage() { sigset_t new_mask; sigset_t orig_mask; @@ -808,8 +824,10 @@ void SaverEngine::waitForLockEngage() { sigaddset(&new_mask, SIGTTIN); sigprocmask(SIG_BLOCK, &new_mask, &orig_mask); - while ((mState != Waiting) && (mState != Saving)) { + while ((mLockProcess.isRunning()) && (mState != Waiting) && (mState != Saving)) { sigsuspend(&orig_mask); } sigprocmask(SIG_UNBLOCK, &new_mask, NULL); + + return mLockProcess.isRunning(); }
\ No newline at end of file |