Use setrlimit to set a correct value for maxfilesperproc.
Disable the kqueue(2) backend for now (by setting max_open_files to the minimum) as there are some weird corner cases where it doesn't work and hangs gam_server. I'm still on that but for the time beeing we want this to work in every situations.
This commit is contained in:
parent
ae3bdd934d
commit
1b582b7296
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.2 2009/12/05 17:03:40 ajacoutot Exp $
|
||||
# $OpenBSD: Makefile,v 1.3 2009/12/05 22:55:36 ajacoutot Exp $
|
||||
|
||||
COMMENT-main= file and directory monitoring system
|
||||
COMMENT-server= gamin file monitoring server
|
||||
@ -8,7 +8,7 @@ GNOME_PROJECT= gamin
|
||||
GNOME_VERSION= 0.1.10
|
||||
|
||||
PKGNAME-main= libgamin-${GNOME_VERSION}
|
||||
PKGNAME-server= ${DISTNAME}p0
|
||||
PKGNAME-server= ${DISTNAME}p1
|
||||
PKGNAME-python= py-gamin-${GNOME_VERSION}
|
||||
|
||||
SHARED_LIBS += gamin-1 0.0 # .1.10
|
||||
|
@ -1,4 +1,4 @@
|
||||
$OpenBSD: patch-server_gam_kqueue_c,v 1.2 2009/12/05 17:03:40 ajacoutot Exp $
|
||||
$OpenBSD: patch-server_gam_kqueue_c,v 1.3 2009/12/05 22:55:36 ajacoutot Exp $
|
||||
|
||||
From FreeBSD:
|
||||
Make sure that excluded paths do not get opened (but rather they will be
|
||||
@ -9,10 +9,11 @@ OpenBSD doesn't have sysctlbyname, use sysctl(3) instead.
|
||||
Fix "enumeration value... not handled in switch" warnings.
|
||||
|
||||
OpenBSD does not have maxfilesperproc, which means max_open_files will
|
||||
default to "0" and kqueue will never be used.
|
||||
default to "0" and kqueue will never be used. Instead, use get+setrlimit
|
||||
to get a correct value.
|
||||
|
||||
--- server/gam_kqueue.c.orig Wed Jul 4 15:50:41 2007
|
||||
+++ server/gam_kqueue.c Sat Dec 5 17:40:55 2009
|
||||
+++ server/gam_kqueue.c Sat Dec 5 23:10:14 2009
|
||||
@@ -31,7 +31,8 @@
|
||||
* - kqueue needs to be moved out the UFS code.
|
||||
*
|
||||
@ -23,11 +24,12 @@ default to "0" and kqueue will never be used.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -58,10 +59,12 @@
|
||||
@@ -58,10 +59,13 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/event.h>
|
||||
#include <sys/time.h>
|
||||
+#include <sys/mount.h>
|
||||
+#include <err.h>
|
||||
#include <errno.h>
|
||||
#include "gam_error.h"
|
||||
#include "gam_kqueue.h"
|
||||
@ -36,7 +38,7 @@ default to "0" and kqueue will never be used.
|
||||
#include "gam_server.h"
|
||||
#include "gam_poll_basic.h"
|
||||
|
||||
@@ -323,20 +326,6 @@ gam_kqueue_isdir (const char *pathname, MonitorFlags f
|
||||
@@ -323,20 +327,6 @@ gam_kqueue_isdir (const char *pathname, MonitorFlags f
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +59,7 @@ default to "0" and kqueue will never be used.
|
||||
/*** HashTable ***************************************************************/
|
||||
|
||||
static HashTable *
|
||||
@@ -509,33 +498,49 @@ static gboolean
|
||||
@@ -509,33 +499,49 @@ static gboolean
|
||||
gam_kqueue_monitor_enable_kqueue (Monitor *mon)
|
||||
{
|
||||
struct kevent ev[1];
|
||||
@ -66,16 +68,16 @@ default to "0" and kqueue will never be used.
|
||||
if (open_files == max_open_files)
|
||||
{
|
||||
GAM_DEBUG(DEBUG_INFO, "cannot open %s (max_open_files limit reached), falling back to poll\n", mon->pathname);
|
||||
+ goto poll;
|
||||
+ }
|
||||
+
|
||||
+ if (gam_exclude_check(mon->pathname))
|
||||
+ {
|
||||
+ GAM_DEBUG(DEBUG_INFO, "not using kqueue for %s since it is excluded, falling back to poll\n", mon->pathname);
|
||||
return FALSE;
|
||||
}
|
||||
-
|
||||
- mon->fd = open(mon->pathname, O_RDONLY | O_NOFOLLOW);
|
||||
+
|
||||
+ if (gam_exclude_check(mon->pathname))
|
||||
+ {
|
||||
+ GAM_DEBUG(DEBUG_INFO, "not using kqueue for %s since it is excluded, falling back to poll\n", mon->pathname);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ mon->fd = open(mon->pathname, O_RDONLY | O_NONBLOCK | O_NOFOLLOW);
|
||||
if (mon->fd < 0)
|
||||
@ -113,7 +115,7 @@ default to "0" and kqueue will never be used.
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -840,6 +845,9 @@ gam_kqueue_sub_monitor_emit_event (SubMonitor *smon,
|
||||
@@ -840,6 +846,9 @@ gam_kqueue_sub_monitor_emit_event (SubMonitor *smon,
|
||||
case GAMIN_EVENT_MOVED:
|
||||
gam_kqueue_sub_monitor_set_missing(smon);
|
||||
break;
|
||||
@ -123,7 +125,7 @@ default to "0" and kqueue will never be used.
|
||||
}
|
||||
|
||||
gam_server_emit_event(mon->pathname, isdir, event, smon->subs, 1);
|
||||
@@ -981,6 +989,9 @@ gam_kqueue_file_monitor_emit_event (FileMonitor *fmon,
|
||||
@@ -981,6 +990,9 @@ gam_kqueue_file_monitor_emit_event (FileMonitor *fmon,
|
||||
|
||||
gam_kqueue_hash_table_remove(fmon->smon->fmons, fmon);
|
||||
break;
|
||||
@ -133,7 +135,7 @@ default to "0" and kqueue will never be used.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1133,10 +1144,15 @@ gam_kqueue_init (void)
|
||||
@@ -1133,11 +1145,17 @@ gam_kqueue_init (void)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -150,9 +152,11 @@ default to "0" and kqueue will never be used.
|
||||
- return FALSE;
|
||||
+}
|
||||
|
||||
+
|
||||
/*
|
||||
* We make sure to:
|
||||
@@ -1145,9 +1161,13 @@ gam_kqueue_init (void)
|
||||
* - never paralyze the system (CFG_GLOBAL_FILE_RESERVE_RATIO)
|
||||
@@ -1145,9 +1163,28 @@ gam_kqueue_init (void)
|
||||
*/
|
||||
|
||||
maxfiles *= CFG_GLOBAL_FILE_RESERVE_RATIO;
|
||||
@ -161,7 +165,22 @@ default to "0" and kqueue will never be used.
|
||||
? maxfilesperproc - CFG_SELF_FILE_RESERVE
|
||||
: 0;
|
||||
+#else
|
||||
+ maxfilesperproc = maxfiles;
|
||||
+ maxfilesperproc = 128;
|
||||
+ struct rlimit rlp;
|
||||
+ if (getrlimit(RLIMIT_NOFILE, &rlp) == 0)
|
||||
+ {
|
||||
+ rlp.rlim_cur = rlp.rlim_max;
|
||||
+ if (setrlimit(RLIMIT_NOFILE, &rlp) < -1)
|
||||
+ {
|
||||
+ gam_error(DEBUG_INFO, "cannot unlimit number of open files\n");
|
||||
+ err(1, "setrlimit");
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+// XXX kqueue hangs
|
||||
+// maxfilesperproc = rlp.rlim_max;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
|
||||
max_open_files = MIN(maxfiles, maxfilesperproc);
|
||||
|
Loading…
Reference in New Issue
Block a user