Eliminate usleep() loop during kdesktop startup

Do not switch desktops if lock fails to engage
(cherry picked from commit 751c96f9b1)
pull/182/head
Timothy Pearson 9 years ago committed by Slávek Banko
parent 6dd6500446
commit 0621ed70db

@ -911,7 +911,9 @@ void KRootWm::doNewSession( bool lock )
if (lock) { if (lock) {
m_pSaver->lockScreen(); m_pSaver->lockScreen();
m_pSaver->waitForLockEngage(); if (!m_pSaver->waitForLockEngage()) {
return;
}
} }
DM().startReserve(); DM().startReserve();

@ -415,13 +415,9 @@ bool SaverEngine::restartDesktopLockProcess()
return false; return false;
} }
// Wait for the saver process to signal ready... // Wait for the saver process to signal ready...
int count = 0; if (!waitForLockProcessStart()) {
while (!mSaverProcessReady) { kdDebug( 1204 ) << "Failed to initialize kdesktop_lock (unexpected termination)!" << endl;
count++; return false;
usleep(100);
if (count > 100) {
return false;
}
} }
} }
return true; 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 new_mask;
sigset_t orig_mask; sigset_t orig_mask;
@ -808,8 +824,10 @@ void SaverEngine::waitForLockEngage() {
sigaddset(&new_mask, SIGTTIN); sigaddset(&new_mask, SIGTTIN);
sigprocmask(SIG_BLOCK, &new_mask, &orig_mask); sigprocmask(SIG_BLOCK, &new_mask, &orig_mask);
while ((mState != Waiting) && (mState != Saving)) { while ((mLockProcess.isRunning()) && (mState != Waiting) && (mState != Saving)) {
sigsuspend(&orig_mask); sigsuspend(&orig_mask);
} }
sigprocmask(SIG_UNBLOCK, &new_mask, NULL); sigprocmask(SIG_UNBLOCK, &new_mask, NULL);
return mLockProcess.isRunning();
} }

@ -89,7 +89,7 @@ public:
* Called by KDesktop to wait for saver engage * Called by KDesktop to wait for saver engage
* @internal * @internal
*/ */
void waitForLockEngage(); bool waitForLockEngage();
public slots: public slots:
void slotLockProcessWaiting(); void slotLockProcessWaiting();
@ -125,6 +125,7 @@ protected:
enum SaverState { Waiting, Preparing, Engaging, Saving }; enum SaverState { Waiting, Preparing, Engaging, Saving };
enum LockType { DontLock, DefaultLock, ForceLock, SecureDialog }; enum LockType { DontLock, DefaultLock, ForceLock, SecureDialog };
bool startLockProcess( LockType lock_type ); bool startLockProcess( LockType lock_type );
bool waitForLockProcessStart();
void stopLockProcess(); void stopLockProcess();
bool handleKeyPress(XKeyEvent *xke); bool handleKeyPress(XKeyEvent *xke);
void processLockTransactions(); void processLockTransactions();

Loading…
Cancel
Save