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

List:       kde-core-devel
Subject:    Re: KDirWatch still causes crashes
From:       Josef Weidendorfer <Josef.Weidendorfer () gmx ! de>
Date:       2002-03-28 12:45:44
[Download RAW message or body]

On Tuesday 26 March 2002 10:35, Michael Brade wrote:
...
> Ahh, I see. Open Konqy (will be /home/michael for me), go to tmp, go to
> test, go to folder (so all the three are watched). Open a konsole, go to
> tmp and type "mv test new" -> crash. Carsten mentioned to recompile
> something but it didn't help yet (I recompiled kdelibs/kio after the last
> kdirwatch commit and konqy).

I think I found the bug for the STAT case; somebody already tried to
fix possible crashes when watched dirs are removed in emitting a dirty signal.
Unfortunately, this wasn't quite right, so I the dirty paths are now 
buffered...
With FAM, a bug slipped also in for FAM events of already removed watches.

Can someone check the above crash case with and without FAM?
Waldo, can you commit for 3.0.1, if the crash is gone
(this time I really compiled and tested it before sending this EMail :-)

Cheers,
Josef

PS: There is a patch for DNOTIFY support of the FAM daemon available.
I think, this is the best thing to use because IMON isn't in the standard 
LINUX kernel and the FAM daemon has no problems with the DNOTIFY bug (no 
child processes).

===================================================================
RCS file: /home/kde/kdelibs/kio/kio/kdirwatch.cpp,v
retrieving revision 1.71
diff -u -3 -p -r1.71 kdirwatch.cpp
--- kdirwatch.cpp       2002/03/25 00:55:38     1.71
+++ kdirwatch.cpp       2002/03/28 12:43:15
@@ -838,9 +838,9 @@ void KDirWatchPrivate::emitEvent(Entry*
 }

 struct EmitEntry {
-  EmitEntry(KDirWatchPrivate::Entry _entry, int _event)
-    : entry(_entry), event(_event) {};
-  KDirWatchPrivate::Entry entry; int event;
+  EmitEntry(QString _path, int _event)
+    : path(_path), event(_event) {};
+  QString path; int event;
 };

 /* Scan all entries to be watched for changes. This is done regularly
@@ -850,7 +850,7 @@ void KDirWatchPrivate::slotRescan()
 {
   EntryMap::Iterator it;

-  // Buffer events to be emitted, so that it won't crash if an app
+  // Buffer dirty entry paths, so that it won't crash if an app
   // calls removeDir() in slotDirty().
   QPtrList<EmitEntry> emitList;
   emitList.setAutoDelete(true);
@@ -898,11 +898,12 @@ void KDirWatchPrivate::slotRescan()
 #endif

     if ( ev != NoChange )
-      emitList.append(new EmitEntry(*it, ev));
+      emitList.append(new EmitEntry((*it).path, ev));
   }

   for(EmitEntry* e = emitList.first(); e; e = emitList.next() ) {
-    emitEvent( &e->entry, e->event);
+    if (m_mapEntries.contains( e->path ))
+      emitEvent( & m_mapEntries[e->path], e->event);
   }

 #ifdef HAVE_DNOTIFY
@@ -958,7 +959,16 @@ void KDirWatchPrivate::checkFAMEvent(FAM
     if (strncmp(fe->filename, ".xsession-errors", 16) == 0) return;
   }

-  Entry* e = static_cast<Entry*>(fe->userdata);
+  Entry* e = 0;
+  EntryMap::Iterator it = m_mapEntries.begin();
+  for( ; it != m_mapEntries.end(); ++it )
+    if (FAMREQUEST_GETREQNUM(&( (*it).fr )) ==
+       FAMREQUEST_GETREQNUM(&(fe->fr)) ) {
+      e = &(*it);
+      break;
+    }
+
+  // Entry* e = static_cast<Entry*>(fe->userdata);

   kdDebug(7001) << "Processing FAM event ("
                << ((fe->code == FAMChanged) ? "FAMChanged" :
@@ -971,7 +981,7 @@ void KDirWatchPrivate::checkFAMEvent(FAM
                    (fe->code == FAMExists) ? "FAMExists" :
                    (fe->code == FAMEndExist) ? "FAMEndExist" : "Unknown 
Code")
                << ", " << fe->filename
-               << ", Req " << FAMREQUEST_GETREQNUM(&(e->fr))
+               << ", Req " << FAMREQUEST_GETREQNUM(&(fe->fr))
                << ")" << endl;

   if (!e) {

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

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