};
typedef struct _tp_kqueue_data tp_kqueue_data;
-static void tp_kqueue_modify (gpointer event_data, int fd, int operation, int events, gboolean is_new);
+static void tp_kqueue_modify (gpointer p, int fd, int operation, int events, gboolean is_new);
static void tp_kqueue_shutdown (gpointer event_data);
static void tp_kqueue_wait (gpointer event_data);
}
static void
-tp_kqueue_modify (gpointer event_data, int fd, int operation, int events, gboolean is_new)
+tp_kqueue_modify (gpointer p, int fd, int operation, int events, gboolean is_new)
{
- tp_kqueue_data *data = event_data;
+ SocketIOData *socket_io_data;
+ socket_io_data = p;
+ tp_kqueue_data *data = socket_io_data->event_data;
struct kevent evt;
+ memset (&evt, 0, sizeof (evt));
if ((events & MONO_POLLIN) != 0) {
EV_SET (&evt, fd, EVFILT_READ, EV_ADD | EV_ENABLE | EV_ONESHOT, 0, 0, 0);
kevent_change (data->fd, &evt, "ADD read");
EV_SET (&evt, fd, EVFILT_WRITE, EV_ADD | EV_ENABLE | EV_ONESHOT, 0, 0, 0);
kevent_change (data->fd, &evt, "ADD write");
}
+ mono_mutex_unlock (&socket_io_data->io_lock);
}
static void
{
SocketIOData *socket_io_data;
int kfd;
- MonoInternalThread *thread;
struct kevent *events, *evt;
int ready = 0, i;
gpointer async_results [KQUEUE_NEVENTS * 2]; // * 2 because each loop can add up to 2 results here
socket_io_data = p;
data = socket_io_data->event_data;
kfd = data->fd;
- thread = mono_thread_internal_current ();
events = g_new0 (struct kevent, KQUEUE_NEVENTS);
while (1) {
do {
if (ready == -1) {
- if (THREAD_WANTS_A_BREAK (thread))
- mono_thread_interruption_checkpoint ();
+ check_for_interruption_critical ();
}
ready = kevent (kfd, NULL, 0, events, KQUEUE_NEVENTS, NULL);
} while (ready == -1 && errno == EINTR);
return;
}
- EnterCriticalSection (&socket_io_data->io_lock);
+ mono_mutex_lock (&socket_io_data->io_lock);
if (socket_io_data->inited == 3) {
g_free (events);
- LeaveCriticalSection (&socket_io_data->io_lock);
+ mono_mutex_unlock (&socket_io_data->io_lock);
return; /* cleanup called */
}
mono_g_hash_table_remove (socket_io_data->sock_to_state, GINT_TO_POINTER (fd));
}
}
- LeaveCriticalSection (&socket_io_data->io_lock);
+ mono_mutex_unlock (&socket_io_data->io_lock);
threadpool_append_jobs (&async_io_tp, (MonoObject **) async_results, nresults);
- mono_gc_bzero (async_results, sizeof (gpointer) * nresults);
+ mono_gc_bzero_aligned (async_results, sizeof (gpointer) * nresults);
}
}
#undef KQUEUE_NEVENTS