config option for KDirWatch method
Andreas Pakulat
apaku at gmx.de
Tue Aug 7 09:48:06 BST 2007
On 06.08.07 01:59:48, Andreas Pakulat wrote:
> in a KDirWatch related thread some time ago the issue was raised that
> currently there's no way to change the method this class uses for
> watching, because the order is hardcoded (fam, inotify, stat for linux).
> As the available fam-methods are not yet fully stable and one of the
> alternative's can't even be shut down (except by removing the
> server-binary) I'd like to apply the attached patch after discussion.
>
> What it does is simply reading a value from a new group in the
> kdeglobals file (hope I have the KConfig code to get to that config file
> right) and determines which method to prefer based on that.
>
> If a QString is too costly for the key I can change that to an int or
> something else, but I thought this way its easier for a possible kcm to
> be implemented because you don't have to keep the int-values in sync
> with kdirwatch.
>
> This doesn't change API in any way, its BC and SC.
This one applies cleanly with the latest changes to KDirWatch.
Andreas
--
You enjoy the company of other people.
-------------- next part --------------
Index: kio/kio/kdirwatch.cpp
===================================================================
--- kio/kio/kdirwatch.cpp (Revision 697240)
+++ kio/kio/kdirwatch.cpp (Arbeitskopie)
@@ -122,6 +122,19 @@
m_nfsPollInterval = config.readEntry("NFSPollInterval", 5000);
m_PollInterval = config.readEntry("PollInterval", 500);
+ QString method = config.readEntry("PreferredMethod", "INotify");
+ if (method == "Fam")
+ {
+ m_preferredMethod = Fam;
+ }else if (method == "Poll")
+ {
+ m_preferredMethod = Poll;
+ }else
+ {
+ m_preferredMethod = INotify;
+ }
+
+
QString available("Stat");
// used for FAM
@@ -671,17 +684,37 @@
// Now I've put inotify check before famd one, otherwise famd will be used
// also when inotify is available. Since inotify works
// better than famd, it is preferred to the last one
- // TODO: make monitoring system selection configurable at run-time
-
+
+ //First try to use the preferred method, if that fails use the usual order:
+ //inotify,fam,stat
+ bool entryAdded = false;
+ if (m_preferredMethod == Fam)
+ {
+#if defined(HVE_FAM)
+ entryAdded = useFAM(e);
+#endif
+ }else if (m_preferredMethod == INotify)
+ {
#if defined(HAVE_SYS_INOTIFY_H)
- if (useINotify(e)) return;
+ entryAdded = useINotify(e);
#endif
+ }else if (m_preferredMethod == Poll)
+ {
+ entryAdded = useStat(e);
+ }
+
+ if (!entryAdded)
+ {
+#if defined(HAVE_SYS_INOTIFY_H)
+ if (useINotify(e)) return;
+#endif
#if defined(HAVE_FAM)
- if (useFAM(e)) return;
+ if (useFAM(e)) return;
#endif
-
- useStat(e);
+
+ useStat(e);
+ }
}
Index: kio/kio/kdirwatch_p.h
===================================================================
--- kio/kio/kdirwatch_p.h (Revision 697240)
+++ kio/kio/kdirwatch_p.h (Arbeitskopie)
@@ -65,6 +65,9 @@
enum entryMode { UnknownMode = 0, StatMode, DNotifyMode, INotifyMode, FAMMode };
enum { NoChange=0, Changed=1, Created=2, Deleted=4 };
+
+ enum WatchMethod { Poll, Fam, INotify };
+
struct Client {
KDirWatch* instance;
int count;
@@ -148,6 +151,7 @@
QTimer timer;
EntryMap m_mapEntries;
+ WatchMethod m_preferredMethod;
int freq;
int statEntries;
int m_nfsPollInterval, m_PollInterval;
More information about the kde-core-devel
mailing list