summaryrefslogtreecommitdiffstats
path: root/ksmserver
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-04-24 20:22:40 -0500
committerSlávek Banko <slavek.banko@axis.cz>2013-04-25 09:43:43 +0200
commit67afcf177ecfb742d1c90b644795e4e66537fa7f (patch)
treefa866bd2ac36a83cea4e3f3f8cda0596f9c9023e /ksmserver
parent52921d802e2311c746dca62dea86d20cbba0806d (diff)
downloadtdebase-67afcf177ecfb742d1c90b644795e4e66537fa7f.tar.gz
tdebase-67afcf177ecfb742d1c90b644795e4e66537fa7f.zip
Fix long delay at session termination on certain systems
This resolves Bug 760 Add shutdown profiling code and disable at compile time (cherry picked from commit 1c7bdfda1e7c768525a73d1ca104db53ff1cec10)
Diffstat (limited to 'ksmserver')
-rw-r--r--ksmserver/server.cpp10
-rw-r--r--ksmserver/server.h4
-rw-r--r--ksmserver/shutdown.cpp79
3 files changed, 75 insertions, 18 deletions
diff --git a/ksmserver/server.cpp b/ksmserver/server.cpp
index 63a4313b9..4ef60aeaf 100644
--- a/ksmserver/server.cpp
+++ b/ksmserver/server.cpp
@@ -927,6 +927,16 @@ bool KSMServer::isCM( const TQString& program ) const
return (program == "kompmgr");
}
+bool KSMServer::isNotifier( const KSMClient* client ) const
+{
+ return isNotifier( client->program());
+}
+
+bool KSMServer::isNotifier( const TQString& program ) const
+{
+ return (program == "knotify");
+}
+
bool KSMServer::defaultSession() const
{
return sessionGroup.isEmpty();
diff --git a/ksmserver/server.h b/ksmserver/server.h
index 9464d5275..17c72759d 100644
--- a/ksmserver/server.h
+++ b/ksmserver/server.h
@@ -142,11 +142,13 @@ private:
const TQString& clientMachine = TQString::null,
const TQString& userId = TQString::null );
void executeCommand( const TQStringList& command );
-
+
bool isWM( const KSMClient* client ) const;
bool isWM( const TQString& program ) const;
bool isCM( const KSMClient* client ) const;
bool isCM( const TQString& program ) const;
+ bool isNotifier( const KSMClient* client ) const;
+ bool isNotifier( const TQString& program ) const;
bool defaultSession() const; // empty session
void setupXIOErrorHandler();
diff --git a/ksmserver/shutdown.cpp b/ksmserver/shutdown.cpp
index fd1406c3d..40aebd4be 100644
--- a/ksmserver/shutdown.cpp
+++ b/ksmserver/shutdown.cpp
@@ -88,6 +88,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "shutdowndlg.h"
#include "client.h"
+// #define PROFILE_SHUTDOWN 1
+
+#ifdef PROFILE_SHUTDOWN
+ #define SHUTDOWN_MARKER(x) printf("[ksmserver] '%s' [%s]\n\r", x, TQTime::currentTime().toString("hh:mm:ss:zzz").ascii()); fflush(stdout);
+#else // PROFILE_SHUTDOWN
+ #define SHUTDOWN_MARKER(x)
+#endif // PROFILE_SHUTDOWN
+
void KSMServer::logout( int confirm, int sdtype, int sdmode )
{
shutdown( (KApplication::ShutdownConfirm)confirm,
@@ -190,7 +198,7 @@ void KSMServer::shutdownInternal( KApplication::ShutdownConfirm confirm,
}
if ( logoutConfirmed ) {
-
+ SHUTDOWN_MARKER("Shutdown initiated");
shutdownType = sdtype;
shutdownMode = sdmode;
bootOption = bopt;
@@ -199,8 +207,9 @@ void KSMServer::shutdownInternal( KApplication::ShutdownConfirm confirm,
// shall we save the session on logout?
saveSession = ( config->readEntry( "loginMode", "restorePreviousLogout" ) == "restorePreviousLogout" );
- if ( saveSession )
+ if ( saveSession ) {
sessionGroup = TQString("Session: ") + SESSION_PREVIOUS_LOGOUT;
+ }
// Set the real desktop background to black so that exit looks
// clean regardless of what was on "our" desktop.
@@ -211,6 +220,7 @@ void KSMServer::shutdownInternal( KApplication::ShutdownConfirm confirm,
wmPhase1WaitingCount = 0;
saveType = saveSession?SmSaveBoth:SmSaveGlobal;
performLegacySessionSave();
+ SHUTDOWN_MARKER("Legacy save complete");
startProtection();
for ( KSMClient* c = clients.first(); c; c = clients.next() ) {
c->resetState();
@@ -240,8 +250,9 @@ void KSMServer::shutdownInternal( KApplication::ShutdownConfirm confirm,
SmsSaveYourself( c->connection(), saveType,
true, SmInteractStyleAny, false );
}
- if ( clients.isEmpty() )
+ if ( clients.isEmpty() ) {
completeShutdownOrCheckpoint();
+ }
}
else {
if (showLogoutStatusDlg) {
@@ -474,12 +485,15 @@ void KSMServer::protectionTimeout()
void KSMServer::completeShutdownOrCheckpoint()
{
- if ( state != Shutdown && state != Checkpoint )
+ SHUTDOWN_MARKER("completeShutdownOrCheckpoint");
+ if ( state != Shutdown && state != Checkpoint ) {
return;
+ }
for ( KSMClient* c = clients.first(); c; c = clients.next() ) {
- if ( !c->saveYourselfDone && !c->waitForPhase2 )
+ if ( !c->saveYourselfDone && !c->waitForPhase2 ) {
return; // not done yet
+ }
}
// do phase 2
@@ -491,8 +505,10 @@ void KSMServer::completeShutdownOrCheckpoint()
waitForPhase2 = true;
}
}
- if ( waitForPhase2 )
+ if ( waitForPhase2 ) {
return;
+ }
+ SHUTDOWN_MARKER("Phase 2 complete");
bool showLogoutStatusDlg = KConfigGroup(KGlobal::config(), "Logout").readBoolEntry("showLogoutStatusDlg", true);
if (showLogoutStatusDlg && state != Checkpoint) {
@@ -513,10 +529,14 @@ void KSMServer::completeShutdownOrCheckpoint()
static_cast<KSMShutdownIPDlg*>(shutdownNotifierIPDlg)->setStatusMessage(i18n("Saving your settings..."));
}
- if ( saveSession )
+ if ( saveSession ) {
storeSession();
- else
+ SHUTDOWN_MARKER("Session stored");
+ }
+ else {
discardSession();
+ SHUTDOWN_MARKER("Session discarded");
+ }
if ( state == Shutdown ) {
bool waitForKNotify = true;
@@ -532,8 +552,9 @@ void KSMServer::completeShutdownOrCheckpoint()
}
// event() can return -1 if KNotifyClient short-circuits and avoids KNotify
logoutSoundEvent = KNotifyClient::event( 0, "exitkde" ); // KDE says good bye
- if( logoutSoundEvent <= 0 )
+ if( logoutSoundEvent <= 0 ) {
waitForKNotify = false;
+ }
if( waitForKNotify ) {
state = WaitingForKNotify;
knotifyTimeoutTimer.start( 20000, true );
@@ -546,15 +567,17 @@ void KSMServer::completeShutdownOrCheckpoint()
}
state = Idle;
}
+ SHUTDOWN_MARKER("Fully shutdown");
}
void KSMServer::startKilling()
{
+ SHUTDOWN_MARKER("startKilling");
knotifyTimeoutTimer.stop();
// kill all clients
state = Killing;
for ( KSMClient* c = clients.first(); c; c = clients.next() ) {
- if( isWM( c ) || isCM( c ) ) // kill the WM and CM as the last one in order to reduce flicker
+ if( isWM( c ) || isCM( c ) || isNotifier( c ) ) // kill the WM and CM as the last one in order to reduce flicker. Also wait to kill knotify to avoid logout delays
continue;
kdDebug( 1218 ) << "completeShutdown: client " << c->program() << "(" << c->clientId() << ")" << endl;
SmsDie( c->connection() );
@@ -568,12 +591,13 @@ void KSMServer::startKilling()
void KSMServer::completeKilling()
{
+ SHUTDOWN_MARKER("completeKilling");
kdDebug( 1218 ) << "KSMServer::completeKilling clients.count()=" <<
clients.count() << endl;
if( state == Killing ) {
bool wait = false;
for( KSMClient* c = clients.first(); c; c = clients.next()) {
- if( isWM( c ) || isCM( c ) )
+ if( isWM( c ) || isCM( c ) || isNotifier( c ) )
continue;
wait = true; // still waiting for clients to go away
}
@@ -585,6 +609,7 @@ void KSMServer::completeKilling()
void KSMServer::killWM()
{
+ SHUTDOWN_MARKER("killWM");
state = KillingWM;
bool iswm = false;
if (shutdownNotifierIPDlg) {
@@ -600,6 +625,9 @@ void KSMServer::killWM()
if( isCM( c )) {
SmsDie( c->connection() );
}
+ if( isNotifier( c )) {
+ SmsDie( c->connection() );
+ }
}
if( iswm ) {
completeKillingWM();
@@ -611,6 +639,7 @@ void KSMServer::killWM()
void KSMServer::completeKillingWM()
{
+ SHUTDOWN_MARKER("completeKillingWM");
kdDebug( 1218 ) << "KSMServer::completeKillingWM clients.count()=" <<
clients.count() << endl;
if( state == KillingWM ) {
@@ -622,18 +651,26 @@ void KSMServer::completeKillingWM()
// shutdown is fully complete
void KSMServer::killingCompleted()
{
+ SHUTDOWN_MARKER("killingCompleted");
kapp->quit();
}
// called when KNotify performs notification for logout (not when sound is finished though)
void KSMServer::notifySlot(TQString event ,TQString app,TQString,TQString,TQString,int present,int,int,int)
{
- if( state != WaitingForKNotify )
+ SHUTDOWN_MARKER("notifySlot");
+ if( state != WaitingForKNotify ) {
+ SHUTDOWN_MARKER("notifySlot state != WaitingForKNotify");
return;
- if( event != "exitkde" || app != "ksmserver" )
+ }
+ if( event != "exitkde" || app != "ksmserver" ) {
+ SHUTDOWN_MARKER("notifySlot event != \"exitkde\" || app != \"ksmserver\"");
return;
- if( present & KNotifyClient::Sound ) // logoutSoundFinished() will be called
+ }
+ if( present & KNotifyClient::Sound ) { // logoutSoundFinished() will be called
+ SHUTDOWN_MARKER("notifySlot present & KNotifyClient::Sound");
return;
+ }
startKilling();
}
@@ -641,23 +678,30 @@ void KSMServer::notifySlot(TQString event ,TQString app,TQString,TQString,TQStri
// emitted in KNotify only after the sound is finished playing.
void KSMServer::logoutSoundFinished( int event, int )
{
- if( state != WaitingForKNotify )
+ SHUTDOWN_MARKER("logoutSoundFinished");
+ if( state != WaitingForKNotify ) {
return;
- if( event != logoutSoundEvent )
+ }
+ if( event != logoutSoundEvent ) {
return;
+ }
startKilling();
}
void KSMServer::knotifyTimeout()
{
- if( state != WaitingForKNotify )
+ SHUTDOWN_MARKER("knotifyTimeout");
+ if( state != WaitingForKNotify ) {
return;
+ }
startKilling();
}
void KSMServer::timeoutQuit()
{
+ SHUTDOWN_MARKER("timeoutQuit");
for (KSMClient *c = clients.first(); c; c = clients.next()) {
+ SHUTDOWN_MARKER(TQString("SmsDie timeout, client %1 (%2)").arg(c->program()).arg(c->clientId()).ascii());
kdWarning( 1218 ) << "SmsDie timeout, client " << c->program() << "(" << c->clientId() << ")" << endl;
}
killWM();
@@ -665,6 +709,7 @@ void KSMServer::timeoutQuit()
void KSMServer::timeoutWMQuit()
{
+ SHUTDOWN_MARKER("timeoutWMQuit");
if( state == KillingWM ) {
kdWarning( 1218 ) << "SmsDie WM timeout" << endl;
}