[kde-freebsd] QFilesSystemWatcher instead of polling/FAM

Tijl Coosemans tijl at coosemans.org
Mon Aug 2 22:10:52 CEST 2010


On Monday 19 July 2010 14:07:56 Rusty Nejdl wrote:
> On Mon, 19 Jul 2010 12:20:35 +0200, Jaap Boender wrote:
>> On Friday 09 July 2010 02:32:00 Jason E. Hale wrote:
>>>>>> I've attached a patch that makes KDE use QFileSystemWatcher on FreeBSD
>>>>>> which uses kqueue instead of stat. I've been using it for the past few
>>>>>> days and it seems to work rather well.
>> 
>> I've been using the patch (the July 8 version), and it works well
>> for the most part; the only problem is that plasma-desktop runs up
>> to 100% CPU usage every once in a while (and becomes unresponsive),
>> so that I've got to kill and restart.
>> 
>> Looking at the logs, there doesn't seem to be any particular error
>> message, and it doesn't seem to be triggered by any specific action.
>> If you need me to do anything specific for debugging purposes, or
>> need more information, let me know.
> 
> I can completely attest to this and mine was so bad I had to remove
> the patch.  Plasma would die but everything else would work after
> that.

It turns out that Qt uses a continue statement in a do-while loop
thereby creating an infinite loop. The attached patch should solve it.
You have to put it in devel/qt4-corelib/files/ and rebuild that port.

I'm still trying to fix some more issues, but this should already help
a lot, so please give it a try.
-------------- next part --------------
--- src/corelib/io/qfilesystemwatcher_kqueue.cpp.orig	2010-06-02 04:03:17.000000000 +0200
+++ src/corelib/io/qfilesystemwatcher_kqueue.cpp	2010-08-02 15:14:46.000000000 +0200
@@ -250,12 +250,13 @@
         DEBUG() << "QKqueueFileSystemWatcherEngine: waiting for kevents...";
         int r = kevent(kqfd, 0, 0, &kev, 1, 0);
         if (r < 0) {
+            if( errno == EINTR ) continue;
             perror("QKqueueFileSystemWatcherEngine: error during kevent wait");
             return;
         }
 
         QMutexLocker locker(&mutex);
-        do {
+        for ( ; r > 0; r = kevent(kqfd, 0, 0, &kev, 1, &ZeroTimeout)) {
             int fd = kev.ident;
 
             DEBUG() << "QKqueueFileSystemWatcherEngine: processing kevent" << kev.ident << kev.filter;
@@ -335,10 +336,7 @@
                     }
                 }
             }
-
-            // are there any more?
-            r = kevent(kqfd, 0, 0, &kev, 1, &ZeroTimeout);
-        } while (r > 0);
+        }
     }
 }
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/kde-freebsd/attachments/20100802/c2eebf78/attachment.sig 


More information about the kde-freebsd mailing list