$NetBSD: patch-ab,v 1.2 2005/08/30 23:24:33 jlam Exp $ --- server/gam_kqueue.c.orig 2005-08-04 04:17:37.000000000 -0400 +++ server/gam_kqueue.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -325,9 +326,9 @@ gam_kqueue_isdir (const char *pathname, static gboolean gam_kqueue_get_uint_sysctl (const char *name, unsigned int *value) { - unsigned int value_len = sizeof(*value); + size_t value_len = sizeof(*value); - if (sysctlbyname(name, value, &value_len, NULL, 0) < 0) + if (sysctlbyname(name, value, &value_len, (void *)NULL, 0) < 0) { gam_error(DEBUG_INFO, "unable to retrieve %s: %s\n", name, g_strerror(errno)); return FALSE; @@ -1031,7 +1032,7 @@ gam_kqueue_kevent_cb (GIOChannel *source } for (i = 0; i < nevents; i++) - MONITOR(ev[i].udata)->handle_kevent(ev[i].udata, &ev[i]); + MONITOR(ev[i].udata)->handle_kevent(MONITOR(ev[i].udata), &ev[i]); return TRUE; /* keep source */ } @@ -1134,8 +1135,10 @@ gam_kqueue_init (void) if (! gam_kqueue_get_uint_sysctl("kern.maxfiles", &maxfiles)) return FALSE; +#if defined(KERN_MAXFILESPERPROC) if (! gam_kqueue_get_uint_sysctl("kern.maxfilesperproc", &maxfilesperproc)) return FALSE; +#endif /* * We make sure to: @@ -1144,9 +1147,13 @@ gam_kqueue_init (void) */ maxfiles *= CFG_GLOBAL_FILE_RESERVE_RATIO; +#if defined(KERN_MAXFILESPERPROC) maxfilesperproc = maxfilesperproc > CFG_SELF_FILE_RESERVE ? maxfilesperproc - CFG_SELF_FILE_RESERVE : 0; +#else + maxfilesperproc = maxfiles; +#endif max_open_files = MIN(maxfiles, maxfilesperproc);