summaryrefslogtreecommitdiffstats
path: root/kdesktop
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2015-04-08 15:27:25 -0500
committerTimothy Pearson <[email protected]>2015-04-08 15:27:25 -0500
commit751c96f9b1fc01675a1a9d34831104f98adfd84f (patch)
tree73c9105e26780f965baa7a1314a59035f792c0a5 /kdesktop
parenta17bfb0b96f5b255f41d03c3143d1eca04c88e36 (diff)
downloadtdebase-751c96f9b1fc01675a1a9d34831104f98adfd84f.tar.gz
tdebase-751c96f9b1fc01675a1a9d34831104f98adfd84f.zip
Eliminate usleep() loop during kdesktop startup
Do not switch desktops if lock fails to engage
Diffstat (limited to 'kdesktop')
-rw-r--r--kdesktop/krootwm.cc4
-rw-r--r--kdesktop/lockeng.cc36
-rw-r--r--kdesktop/lockeng.h3
3 files changed, 32 insertions, 11 deletions
diff --git a/kdesktop/krootwm.cc b/kdesktop/krootwm.cc
index d12e024ab..72b9f0f5d 100644
--- a/kdesktop/krootwm.cc
+++ b/kdesktop/krootwm.cc
@@ -911,7 +911,9 @@ void KRootWm::doNewSession( bool lock )
if (lock) {
m_pSaver->lockScreen();
- m_pSaver->waitForLockEngage();
+ if (!m_pSaver->waitForLockEngage()) {
+ return;
+ }
}
DM().startReserve();
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
diff --git a/kdesktop/lockeng.h b/kdesktop/lockeng.h
index e7be7a06e..782f779a3 100644
--- a/kdesktop/lockeng.h
+++ b/kdesktop/lockeng.h
@@ -89,7 +89,7 @@ public:
* Called by KDesktop to wait for saver engage
* @internal
*/
- void waitForLockEngage();
+ bool waitForLockEngage();
public slots:
void slotLockProcessWaiting();
@@ -125,6 +125,7 @@ protected:
enum SaverState { Waiting, Preparing, Engaging, Saving };
enum LockType { DontLock, DefaultLock, ForceLock, SecureDialog };
bool startLockProcess( LockType lock_type );
+ bool waitForLockProcessStart();
void stopLockProcess();
bool handleKeyPress(XKeyEvent *xke);
void processLockTransactions();