[tracker] tracker-monitor: add support for GKqueueDirectoryMonitor
- From: Antoine Jacoutot <ajacoutot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tracker-monitor: add support for GKqueueDirectoryMonitor
- Date: Fri, 16 Nov 2012 07:20:09 +0000 (UTC)
commit 0fbb71aeba428789340e53bf10e1d9afbc0f3193
Author: Antoine Jacoutot <ajacoutot gnome org>
Date: Thu Nov 15 20:06:50 2012 +0100
tracker-monitor: add support for GKqueueDirectoryMonitor
kqueue(2) support for BSD systems was recently introduced in GLib. Make
tracker aware of this new backend.
https://bugzilla.gnome.org/show_bug.cgi?id=688371
src/libtracker-miner/tracker-monitor.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-monitor.c b/src/libtracker-miner/tracker-monitor.c
index 2a18165..9b1ab4e 100644
--- a/src/libtracker-miner/tracker-monitor.c
+++ b/src/libtracker-miner/tracker-monitor.c
@@ -23,6 +23,13 @@
#include <string.h>
#include <gio/gio.h>
+#if defined (__OpenBSD__) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#define TRACKER_MONITOR_KQUEUE
+#endif
+
#include "tracker-monitor.h"
#include "tracker-marshal.h"
@@ -119,6 +126,7 @@ static void tracker_monitor_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
+static guint get_kqueue_limit (void);
static guint get_inotify_limit (void);
static GFileMonitor * directory_monitor_new (TrackerMonitor *monitor,
GFile *file);
@@ -296,6 +304,12 @@ tracker_monitor_init (TrackerMonitor *object)
*/
priv->monitor_limit = MAX (priv->monitor_limit, 0);
}
+ else if (strcmp (name, "GKqueueDirectoryMonitor") == 0) {
+ /* Using kqueue(2) */
+ g_message ("Monitor backend is kqueue");
+
+ priv->monitor_limit = get_kqueue_limit ();
+ }
else if (strcmp (name, "GFamDirectoryMonitor") == 0) {
/* Using Fam */
g_message ("Monitor backend is Fam");
@@ -400,6 +414,20 @@ tracker_monitor_get_property (GObject *object,
}
static guint
+get_kqueue_limit (void)
+{
+ guint limit = 400;
+
+#ifdef TRACKER_MONITOR_KQUEUE
+ struct rlimit rl;
+ if (getrlimit (RLIMIT_NOFILE, &rl) == 0)
+ limit = (rl.rlim_cur * 90) / 100;
+#endif /* TRACKER_MONITOR_KQUEUE */
+
+ return limit;
+}
+
+static guint
get_inotify_limit (void)
{
GError *error = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]