tracker-monitor: add support for GKqueueDirectoryMonitor ; pushed upstream.

This commit is contained in:
ajacoutot 2012-11-16 07:22:51 +00:00
parent 12434a6dd8
commit 5f9b92aa16
2 changed files with 22 additions and 29 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.124 2012/11/15 08:38:03 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.125 2012/11/16 07:22:51 ajacoutot Exp $
SHARED_ONLY= Yes
@ -17,7 +17,8 @@ PKGNAME-main= meta-tracker-${VERSION}
PKGNAME-evolution= evolution-meta-tracker-${VERSION}
PKGNAME-nautilus= nautilus-meta-tracker-${VERSION}
REVISION-main = 1
REVISION-main = 2
REVISION-nautilus = 1
# Only get the first x.y which is needed in the PLIST.
# NOTE: when MAJ_V changes, increment TRACKER_VERSION accordingly and bump:

View File

@ -1,15 +1,17 @@
$OpenBSD: patch-src_libtracker-miner_tracker-monitor_c,v 1.8 2012/11/15 08:38:03 ajacoutot Exp $
$OpenBSD: patch-src_libtracker-miner_tracker-monitor_c,v 1.9 2012/11/16 07:22:51 ajacoutot Exp $
https://bugzilla.gnome.org/show_bug.cgi?id=688371
From 0fbb71aeba428789340e53bf10e1d9afbc0f3193 Mon Sep 17 00:00:00 2001
From: Antoine Jacoutot <ajacoutot@gnome.org>
Date: Thu, 15 Nov 2012 19:06:50 +0000
Subject: tracker-monitor: add support for GKqueueDirectoryMonitor
--- src/libtracker-miner/tracker-monitor.c.orig Wed Feb 15 16:19:19 2012
+++ src/libtracker-miner/tracker-monitor.c Thu Nov 15 09:01:55 2012
@@ -23,6 +23,14 @@
+++ src/libtracker-miner/tracker-monitor.c Thu Nov 15 16:51:07 2012
@@ -23,6 +23,13 @@
#include <string.h>
#include <gio/gio.h>
+#if defined (__OpenBSD__) || defined (__FreeBSD__) || defined (__NetBSD__)
+/* getrlimit(2) */
+#if defined (__OpenBSD__) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__APPLE__)
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
@ -19,55 +21,45 @@ https://bugzilla.gnome.org/show_bug.cgi?id=688371
#include "tracker-monitor.h"
#include "tracker-marshal.h"
@@ -119,6 +127,9 @@ static void tracker_monitor_get_property (GO
@@ -119,6 +126,7 @@ static void tracker_monitor_get_property (GO
guint prop_id,
GValue *value,
GParamSpec *pspec);
+#ifdef TRACKER_MONITOR_KQUEUE
+static guint get_kqueue_limit (void);
+#endif
+static guint get_kqueue_limit (void);
static guint get_inotify_limit (void);
static GFileMonitor * directory_monitor_new (TrackerMonitor *monitor,
GFile *file);
@@ -296,6 +307,14 @@ tracker_monitor_init (TrackerMonitor *object)
@@ -296,6 +304,12 @@ tracker_monitor_init (TrackerMonitor *object)
*/
priv->monitor_limit = MAX (priv->monitor_limit, 0);
}
+#if defined TRACKER_MONITOR_KQUEUE
+ else if (strcmp (name, "GKqueueDirectoryMonitor") == 0) {
+ /* Using kqueue(2) */
+ g_message ("Monitor backend is kqueue");
+
+ priv->monitor_limit = get_kqueue_limit ();
+ }
+#endif
else if (strcmp (name, "GFamDirectoryMonitor") == 0) {
/* Using Fam */
g_message ("Monitor backend is Fam");
@@ -398,6 +417,26 @@ tracker_monitor_get_property (GObject *object,
@@ -397,6 +411,20 @@ tracker_monitor_get_property (GObject *object,
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
+}
+
+#ifdef TRACKER_MONITOR_KQUEUE
+static guint
+get_kqueue_limit (void)
+{
+ struct rlimit rl;
+ guint limit = 400;
+
+#ifdef TRACKER_MONITOR_KQUEUE
+ struct rlimit rl;
+ if (getrlimit (RLIMIT_NOFILE, &rl) == 0)
+ limit = (rl.rlim_cur*90)/100;
+
+ /* Prevent from opening an insame amount of FDs
+ * (kqueue(2) opens one file descriptor per monitor).
+ */
+ if (limit > 2048)
+ limit = 2048;
+ limit = (rl.rlim_cur * 90) / 100;
+#endif /* TRACKER_MONITOR_KQUEUE */
+
+ return limit;
+}
+#endif /* TRACKER_MONITOR_KQUEUE */
}
static guint
get_inotify_limit (void)