[kde-freebsd] QFilesSystemWatcher instead of polling/FAM
Tijl Coosemans
tijl at coosemans.org
Mon Aug 9 11:01:56 CEST 2010
On Saturday 07 August 2010 04:34:55 Raphael Kubo da Costa wrote:
> Are you planning on sending these patches upstream?
For the Qt patch there's a merge request here:
http://qt.gitorious.org/qt/qt/merge_requests/2425
I've attached what I believe to be the final version of the kdelibs
patch. It uses polling by default for NFS mounts now and fixes a few
other things. Unless someone finds a problem with it, I'll submit that
as well.
-------------- next part --------------
--- kio/CMakeLists.txt.orig 2010-06-24 14:08:17.000000000 +0200
+++ kio/CMakeLists.txt 2010-06-24 14:08:42.000000000 +0200
@@ -28,11 +28,9 @@
check_include_files(sys/inotify.h SYS_INOTIFY_H_FOUND)
macro_bool_to_01(SYS_INOTIFY_H_FOUND HAVE_SYS_INOTIFY_H)
-if(WIN32)
- # currently for win32 only --> enable it for all in 4.1?
- option(USE_QFILESYSTEMWATCHER "Use QFileSystemWatcher instead polling for KDirWatch" ON)
- macro_bool_to_01(USE_QFILESYSTEMWATCHER HAVE_QFILESYSTEMWATCHER)
-endif(WIN32)
+
+option(USE_QFILESYSTEMWATCHER "Use QFileSystemWatcher instead polling for KDirWatch" ON)
+macro_bool_to_01(USE_QFILESYSTEMWATCHER HAVE_QFILESYSTEMWATCHER)
configure_file(kio/config-kdirwatch.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kio/config-kdirwatch.h )
configure_file(kio/config-strigi.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/kio/config-strigi.h )
--- kio/kio/kdirwatch_p.h.orig 2010-06-24 15:21:37.000000000 +0200
+++ kio/kio/kdirwatch_p.h 2010-06-24 15:21:58.000000000 +0200
@@ -102,7 +102,7 @@
QHash<QString,QFileSystemWatcher*> m_paths;
};
#else
-typedef KFileSystemWatcher QFileSystemWatcher;
+typedef QFileSystemWatcher KFileSystemWatcher;
#endif
#endif
--- kio/kio/kdirwatch.cpp.orig 2010-02-26 19:30:10.000000000 +0100
+++ kio/kio/kdirwatch.cpp 2010-08-08 20:39:38.000000000 +0200
@@ -94,7 +94,7 @@ static KDirWatchPrivate::WatchMethod met
#ifdef Q_OS_WIN
return KDirWatchPrivate::QFSWatch;
#elif defined(Q_OS_FREEBSD)
- return KDirWatchPrivate::Stat;
+ return KDirWatchPrivate::QFSWatch;
#else
return KDirWatchPrivate::INotify;
#endif
@@ -150,7 +150,11 @@ KDirWatchPrivate::KDirWatchPrivate()
m_preferredMethod = methodFromString(method);
// The nfs method defaults to the normal (local) method
+#if defined(Q_OS_FREEBSD)
+ m_nfsPreferredMethod = methodFromString(config.readEntry("nfsPreferredMethod", "Stat"));
+#else
m_nfsPreferredMethod = methodFromString(config.readEntry("nfsPreferredMethod", method));
+#endif
QStringList availableMethods;
@@ -961,7 +965,16 @@ void KDirWatchPrivate::removeEntry(KDirW
#ifdef HAVE_QFILESYSTEMWATCHER
if (e->m_mode == QFSWatchMode) {
- fsWatcher->removePath(e->path);
+ if ( e->m_status == Normal ) {
+ fsWatcher->removePath(e->path);
+ kDebug(7001).nospace() << "Cancelled QFSWatch for " << e->path;
+ }
+ else {
+ if (e->isDir)
+ removeEntry(0, QDir::cleanPath(e->path+"/.."), e);
+ else
+ removeEntry(0, QFileInfo(e->path).absolutePath(), e);
+ }
}
#endif
if (e->m_mode == StatMode) {
@@ -1595,8 +1608,7 @@ void KDirWatchPrivate::fswEventReceived(
EntryMap::Iterator it;
it = m_mapEntries.find(path);
if(it != m_mapEntries.end()) {
- Entry entry = *it; // deep copy to not point to uninialized data (can happen inside emitEvent() )
- Entry *e = &entry;
+ Entry *e = &(*it);
e->dirty = true;
int ev = scanEntry(e);
if (ev != NoChange)
@@ -1607,28 +1619,20 @@ void KDirWatchPrivate::fswEventReceived(
else
addEntry(0, QFileInfo(e->path).absolutePath(), e, true);
} else
+ if(ev == Created) {
+ if(!useQFSWatch(e))
+#ifdef HAVE_SYS_INOTIFY_H
+ if(!useINotify(e))
+#endif
+ useStat(e);
+ } else
if (ev == Changed && e->isDir && e->m_entries.count()) {
Entry* sub_entry = 0;
Q_FOREACH(sub_entry, e->m_entries) {
- if(e->isDir) { // ####### !?!? Already checked above
- if (QFileInfo(sub_entry->path).isDir()) // ##### !? no comparison between sub_entry->path and path?
- break;
- } else {
- if (QFileInfo(sub_entry->path).isFile())
- break;
- }
+ if (QFileInfo(sub_entry->path).exists())
+ break;
}
if (sub_entry) {
- removeEntry(0, e, sub_entry);
- //KDE_struct_stat stat_buf;
- //QByteArray tpath = QFile::encodeName(path);
- //KDE_stat(tpath, &stat_buf);
-
- if(!useQFSWatch(sub_entry))
-#ifdef HAVE_SYS_INOTIFY_H
- if(!useINotify(sub_entry))
-#endif
- useStat(sub_entry);
fswEventReceived(sub_entry->path);
}
}
-------------- 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/20100809/f1f893a4/attachment.sig
More information about the kde-freebsd
mailing list