[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    KNotify undo crash handler patch
From:       Stefan Westerfeld <stefan () space ! twc ! de>
Date:       2000-09-23 13:20:20
[Download RAW message or body]

Hi!

Well, as I said, I don't think a crash handler which disables artsd based
notification permanently and forever is a good idea. So I looked at the code,
and removed it again. Here is the patch.

I also removed QIOManager, for the reason that it is a very likely cause for
very unexpected behaviour (which could well be the cause of crashes anyway).

There is a comment in the original source (which is also gone now), like:

-/*
- * This is global because it needs to be initialized *before* the KNotify
- * DCOP object will accept requests (otherwise there may be reentrancy issues
- * and race conditions)
- */

which was meant to *WARN* about calling connectServer in any other place than
the initialization (in main). Well, reconnect obviously IS another place than
intialization, and thus knotify in the form before this patch is subject to
reentrancy.

I.e.
  DCOP request comes in, play sound.
    MCOP needs to reconnect artsd (waits for result).
      DCOP request comes in, play sound.         <--- reentrancy here
	    MCOP needs to reconnect artsd
		  ... crash here? ...

Whatever. Not using QIOManager should remove this reentrancy issue (as it
really blocks while doing MCOP stuff), and make usage pretty safe. QIOManager
isn't tested that good anyway (for instance it is also *not* used in
artscontrol).

Please test, review and apply it - or tell me whats wrong with it ;).

   Cu... Stefan
-- 
  -* Stefan Westerfeld, stefan@space.twc.de (PGP!), Hamburg/Germany
     KDE Developer, project infos at http://space.twc.de/~stefan/kde *-         

["knotify-undo-crash-handler.diff" (text/plain)]

Index: knotify.cpp
===================================================================
RCS file: /home/kde/kdelibs/arts/knotify/knotify.cpp,v
retrieving revision 1.38
diff -u -r1.38 knotify.cpp
--- knotify.cpp	2000/09/23 04:34:06	1.38
+++ knotify.cpp	2000/09/23 13:04:55
@@ -57,15 +57,7 @@
     bool useExternal;
 };
 
-/*
- * This is global because it needs to be initialized *before* the KNotify
- * DCOP object will accept requests (otherwise there may be reentrancy issues
- * and race conditions
- */
-
 Arts::SimpleSoundServer g_soundServer;
-bool enableAudio;
-
 
 bool connectSoundServer()
 {
@@ -113,23 +105,9 @@
     KUniqueApplication app;
     app.disableSessionManagement();
 
-	KCrash::setCrashHandler(KNotify::crashHandler);
-	{ // check if we should shouldn't allow sound events..
-		char file[512];
-		sprintf(file, "%s/.knotify-noaudio", getenv("HOME"));	
-		int fd=open(file, O_RDONLY);
-		enableAudio=(fd==-1);
-		if (fd!=-1)
-			close(fd);
-	}
-
-	// setup mcop communication
-	if (enableAudio)
-	{
-    	Arts::QIOManager qiomanager;
-    	Arts::Dispatcher dispatcher(&qiomanager);
-    	g_soundServer = Arts::SimpleSoundServer::null();
-	}
+    // setup mcop communication
+    Arts::Dispatcher dispatcher;
+    g_soundServer = Arts::SimpleSoundServer::null();
 
     // start notify service
     KNotify notify;
@@ -256,15 +234,12 @@
 	soundFile = locate( "sound", sound );
 
     // Oh dear! we seem to have lost our connection to artsd!
-    if( enableAudio && !external && (g_soundServer.isNull() || g_soundServer.error()) )
+    if( !external && (g_soundServer.isNull() || g_soundServer.error()) )
         connectSoundServer();
 
     kdDebug() << "KNotify::notifyBySound - trying to play file " << soundFile << endl;
     
     if (!external && !g_soundServer.isNull() && !g_soundServer.error()) {
-		if (!enableAudio)
-			return false;
-				
         // play sound finally
         g_soundServer.play( QFile::encodeName(soundFile).data() );
 
@@ -338,16 +313,3 @@
 {
     return d->globalEvents->hasGroup( eventname );
 }
-
-void KNotify::crashHandler(int)
-{
-	// try to save the fact knotify likes to crash...
-	char file[512];
-	sprintf(file, "%s/.knotify-noaudio", getenv("HOME"));
-	int fd=creat(file, O_RDWR);
-	close(fd);
-		
-	_exit(255);
-}
-
-


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic