Fixes for launchd

This commit is contained in:
Lubos Dolezel 2017-07-10 16:02:01 +02:00
parent 284c5896a6
commit 3605093fd5
2 changed files with 12 additions and 2 deletions

View File

@ -377,14 +377,20 @@ kevent64_impl(int kqfd, const struct kevent64_s *changelist, int nchanges,
if (nevents > MAX_KEVENT)
nevents = MAX_KEVENT;
if (nevents > 0) {
rv = kqops.kevent_wait(kq, nevents, (flags & KEVENT_FLAG_IMMEDIATE) ? (&timeout_zero) : timeout);
const struct timespec* ts = (flags & KEVENT_FLAG_IMMEDIATE) ? (&timeout_zero) : timeout;
again:
rv = kqops.kevent_wait(kq, nevents, ts);
dbg_printf("kqops.kevent_wait returned %d", rv);
if (fastpath(rv > 0)) {
kqueue_lock(kq);
rv = kqops.kevent_copyout(kq, rv, eventlist, nevents);
kqueue_unlock(kq);
} else if (rv == 0) {
}
if (rv == 0) {
/* Timeout reached */
/* Avoid returning 0 when waiting indefinitely in case of spurious wakeups */
if (ts == NULL)
goto again;
} else {
dbg_printf("(%u) kevent_wait failed", myid);
goto out;

View File

@ -27,6 +27,7 @@
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include "api.h"
#include "private.h"
@ -37,11 +38,14 @@ int
evfilt_machport_copyout(struct kevent64_s *dst, struct knote *src, void *ptr)
{
struct epoll_event * const ev = (struct epoll_event *) ptr;
uint64_t val;
epoll_event_dump(ev);
kevent_int_to_64(&src->kev, dst);
dst->data = 1024; // TODO: dummy value (message size)
read(src->kn_epollfd, &val, sizeof(val));
return (0);
}