* Gonzalo Paniagua Javier (gonzalo@ximian.com)
*
* Copyright 2004-2009 Novell, Inc (http://www.novell.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_EVENT_H
+#include <sys/event.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
#include <mono/metadata/appdomain.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/filewatcher.h>
MonoDl *fam_module;
int lib_used = 4; /* gamin */
int inotify_instance;
- void *iter;
char *err;
- MONO_ARCH_SAVE_REGS;
-
inotify_instance = ves_icall_System_IO_InotifyWatcher_GetInotifyInstance ();
if (inotify_instance != -1) {
close (inotify_instance);
return 5; /* inotify */
}
- iter = NULL;
fam_module = mono_dl_open ("libgamin-1.so", MONO_DL_LAZY, NULL);
if (fam_module == NULL) {
lib_used = 2; /* FAM */
- iter = NULL;
fam_module = mono_dl_open ("libfam.so", MONO_DL_LAZY, NULL);
}
{
FAMEvent ev;
- MONO_ARCH_SAVE_REGS;
-
if (FAMNextEvent (conn, &ev) == 1) {
*filename = mono_string_new (mono_domain_get (), ev.filename);
*code = ev.code;
char *str, *path;
int retval;
- MONO_ARCH_SAVE_REGS;
-
if (name == NULL)
return -1;
}
#endif
+#if HAVE_KQUEUE
+
+static void
+interrupt_kevent (gpointer data)
+{
+ int *kq_ptr = data;
+
+ /* Interrupt the kevent () call by closing the fd */
+ close (*kq_ptr);
+ /* Signal to managed code that the fd is closed */
+ *kq_ptr = -1;
+}
+
+/*
+ * ves_icall_System_IO_KqueueMonitor_kevent_notimeout:
+ *
+ * Call kevent (), while handling runtime interruptions.
+ */
+int
+ves_icall_System_IO_KqueueMonitor_kevent_notimeout (int *kq_ptr, gpointer changelist, int nchanges, gpointer eventlist, int nevents)
+{
+ int res;
+ gboolean interrupted;
+
+ mono_thread_info_install_interrupt (interrupt_kevent, kq_ptr, &interrupted);
+ if (interrupted) {
+ close (*kq_ptr);
+ *kq_ptr = -1;
+ return -1;
+ }
+
+ MONO_ENTER_GC_SAFE;
+ res = kevent (*kq_ptr, changelist, nchanges, eventlist, nevents, NULL);
+ MONO_EXIT_GC_SAFE;
+
+ mono_thread_info_uninstall_interrupt (&interrupted);
+
+ return res;
+}
+
+#else
+
+int
+ves_icall_System_IO_KqueueMonitor_kevent_notimeout (int *kq_ptr, gpointer changelist, int nchanges, gpointer eventlist, int nevents)
+{
+ g_assert_not_reached ();
+ return -1;
+}
+
+#endif /* #if HAVE_KQUEUE */
+