diff -ruN kdelibs4.orig/Makefile kdelibs4/Makefile --- kdelibs4.orig/Makefile 2010-01-05 15:54:48.000000000 +0100 +++ kdelibs4/Makefile 2010-01-05 15:56:14.000000000 +0100 @@ -55,10 +55,10 @@ assistant svg qdbusviewer makeqpf imageformats \ qmake_build moc_build rcc_build uic_build USE_GNOME= libxml2 libxslt +USE_FAM= yes MAKE_JOBS_SAFE= yes -CMAKE_ARGS+= -DWITH_FAM:BOOL=Off \ - -DWITH_ACL:BOOL=Off +CMAKE_ARGS+= -DWITH_ACL:BOOL=Off MAN1= checkXML.1 \ kde4-config.1 \ diff -ruN kdelibs4.orig/files/patch-kio-kio-kdirwatch.cpp kdelibs4/files/patch-kio-kio-kdirwatch.cpp --- kdelibs4.orig/files/patch-kio-kio-kdirwatch.cpp 2010-01-05 15:54:48.000000000 +0100 +++ kdelibs4/files/patch-kio-kio-kdirwatch.cpp 2010-01-06 17:16:08.000000000 +0100 @@ -1,21 +1,175 @@ ---- ./kio/kio/kdirwatch.cpp.orgi 2009-01-27 18:07:49.000000000 +0100 -+++ ./kio/kio/kdirwatch.cpp 2009-01-27 18:15:04.000000000 +0100 -@@ -89,6 +89,9 @@ - } else if (method == "QFSWatch") { - return KDirWatchPrivate::QFSWatch; - } else { -+#ifdef Q_OS_FREEBSD -+ return KDirWatchPrivate::Stat; -+#endif +--- kio/kio/kdirwatch.cpp.orig 2010-01-05 15:15:22.000000000 +0100 ++++ kio/kio/kdirwatch.cpp 2010-01-06 17:14:10.000000000 +0100 +@@ -92,7 +92,7 @@ #ifdef Q_OS_WIN return KDirWatchPrivate::QFSWatch; + #elif defined(Q_OS_FREEBSD) +- return KDirWatchPrivate::Stat; ++ return KDirWatchPrivate::Fam; #else -@@ -159,7 +162,7 @@ + return KDirWatchPrivate::INotify; + #endif +@@ -161,7 +161,7 @@ #ifdef HAVE_FAM // It's possible that FAM server can't be started - if (FAMOpen(&fc) ==0) { -+ if (m_preferredMethod == Fam && FAMOpen(&fc) ==0) { ++ if (m_preferredMethod == Fam && FAMOpen(&fc) == 0) { availableMethods << "FAM"; use_fam=true; sn = new QSocketNotifier( FAMCONNECTION_GETFD(&fc), +@@ -521,10 +521,6 @@ + { + if (!use_fam) return false; + +- // handle FAM events to avoid deadlock +- // (FAM sends back all files in a directory when monitoring) +- famEventReceived(); +- + e->m_mode = FAMMode; + e->dirty = false; + +@@ -534,6 +530,11 @@ + addEntry(0, QDir::cleanPath(e->path+"/.."), e, true); + } + else { ++ // After adding a monitor request for a directory, FAM sends a FAMExists event for ++ // each existing file in that directory followed by a FAMExistsEnd event. Cache ++ // them to prevent deadlocks. ++ cacheFAMEvent(); ++ + int res =FAMMonitorDirectory(&fc, QFile::encodeName(e->path), + &(e->fr), e); + if (res<0) { +@@ -552,6 +553,10 @@ + addEntry(0, QFileInfo(e->path).absolutePath(), e, true); + } + else { ++ // After adding a monitor request for a file, FAM sends a FAMExists event. Cache ++ // it to prevent deadlocks. ++ cacheFAMEvent(); ++ + int res = FAMMonitorFile(&fc, QFile::encodeName(e->path), + &(e->fr), e); + if (res<0) { +@@ -566,9 +571,10 @@ + } + } + +- // handle FAM events to avoid deadlock +- // (FAM sends back all files in a directory when monitoring) +- famEventReceived(); ++ // Process previously cached events. Events that haven't arrived yet will be ++ // handled by the socket notifier ++ if (!m_eventCache.isEmpty()) ++ famEventReceived(); + + return true; + } +@@ -881,6 +887,10 @@ + #ifdef HAVE_FAM + if (e->m_mode == FAMMode) { + if ( e->m_status == Normal) { ++ // For each cancelled file or directory FAM sends a FAMAcknowledge event. ++ // Cache it to prevent deadlocks. ++ cacheFAMEvent(); ++ + FAMCancelMonitor(&fc, &(e->fr) ); + kDebug(7001).nospace() << "Cancelled FAM (Req " << FAMREQUEST_GETREQNUM(&(e->fr)) + << ") for " << e->path; +@@ -959,6 +969,13 @@ + foreach(const QString &path, pathList) + removeEntry(instance, path, 0); + ++#ifdef HAVE_FAM ++ // Process previously cached events. Events that haven't arrived yet will be ++ // handled by the socket notifier ++ if (use_fam && !m_eventCache.isEmpty()) ++ famEventReceived(); ++#endif ++ + if (minfreq > freq) { + // we can decrease the global polling frequency + freq = minfreq; +@@ -1237,6 +1254,12 @@ + Entry* entry = *removeList.begin(); + removeEntry(0, entry, 0); // this will remove entry from removeList + } ++#ifdef HAVE_FAM ++ // Process previously cached events. Events that haven't arrived yet will be ++ // handled by the socket notifier ++ if (use_fam && !m_eventCache.isEmpty()) ++ famEventReceived(); ++#endif + } + + /* Scan all entries to be watched for changes. This is done regularly +@@ -1344,6 +1367,32 @@ + } + + #ifdef HAVE_FAM ++void KDirWatchPrivate::cacheFAMEvent() ++{ ++ static FAMEvent fe; ++ ++ while(use_fam && FAMPending(&fc)) { ++ if (FAMNextEvent(&fc, &fe) == -1) { ++ kWarning(7001) << "FAM connection problem, switching to polling."; ++ use_fam = false; ++ delete sn; sn = 0; ++ ++ // Replace all FAMMode entries with DNotify/Stat ++ EntryMap::Iterator it; ++ it = m_mapEntries.begin(); ++ for( ; it != m_mapEntries.end(); ++it ) ++ if ((*it).m_mode == FAMMode && (*it).m_clients.count()>0) { ++#ifdef HAVE_SYS_INOTIFY_H ++ if (useINotify( &(*it) )) continue; ++#endif ++ useStat( &(*it) ); ++ } ++ } ++ else ++ m_eventCache.append(fe); ++ } ++} ++ + void KDirWatchPrivate::famEventReceived() + { + static FAMEvent fe; +@@ -1352,6 +1401,12 @@ + + //kDebug(7001) << "Fam event received"; + ++ // First drain the queue of cached events ++ while (!m_eventCache.isEmpty()) { ++ fe = m_eventCache.takeFirst(); ++ checkFAMEvent(&fe); ++ } ++ + while(use_fam && FAMPending(&fc)) { + if (FAMNextEvent(&fc, &fe) == -1) { + kWarning(7001) << "FAM connection problem, switching to polling."; +@@ -1373,7 +1428,10 @@ + checkFAMEvent(&fe); + } + +- QTimer::singleShot(0, this, SLOT(slotRemoveDelayed())); ++ if (!removeList.isEmpty()) ++ QTimer::singleShot(0, this, SLOT(slotRemoveDelayed())); ++ else ++ delayRemove = false; + } + + void KDirWatchPrivate::checkFAMEvent(FAMEvent* fe) +@@ -1440,6 +1498,10 @@ + { + // a watched directory was deleted + ++ // For each cancelled file or directory FAM sends a FAMAcknowledge event. ++ // Cache it to prevent deadlocks. ++ cacheFAMEvent(); ++ + e->m_status = NonExistent; + FAMCancelMonitor(&fc, &(e->fr) ); // needed ? + kDebug(7001) << "Cancelled FAMReq" diff -ruN kdelibs4.orig/files/patch-kio-kio-kdirwatch_p.h kdelibs4/files/patch-kio-kio-kdirwatch_p.h --- kdelibs4.orig/files/patch-kio-kio-kdirwatch_p.h 1970-01-01 01:00:00.000000000 +0100 +++ kdelibs4/files/patch-kio-kio-kdirwatch_p.h 2010-01-05 15:56:33.000000000 +0100 @@ -0,0 +1,12 @@ +--- kio/kio/kdirwatch_p.h.orig 2010-01-05 15:15:37.000000000 +0100 ++++ kio/kio/kdirwatch_p.h 2010-01-05 13:47:21.000000000 +0100 +@@ -238,7 +238,9 @@ + QSocketNotifier *sn; + FAMConnection fc; + bool use_fam; ++ QList m_eventCache; + ++ void cacheFAMEvent(); + void checkFAMEvent(FAMEvent*); + bool useFAM(Entry*); + #endif