1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-26 07:03:16 +00:00

kqueue mirror master branch implementation a bit better.

This commit is contained in:
Calvin Rose 2023-10-07 12:53:59 -07:00
parent 1418ada38f
commit 3905e92965

View File

@ -1658,11 +1658,12 @@ static void timestamp2timespec(struct timespec *t, JanetTimestamp ts) {
}
void janet_register_stream(JanetStream *stream) {
struct kevent kev;
EV_SETx(&kev, stream->handle, EVFILT_READ | EVFILT_WRITE, EV_ADD | EV_ENABLE | EV_CLEAR | EV_EOF, 0, 0, stream);
struct kevent kevs[2];
EV_SETx(&kevs[1], stream->handle, EVFILT_READ, EV_ADD | EV_ENABLE | EV_CLEAR | EV_EOF, 0, 0, stream);
EV_SETx(&kevs[1], stream->handle, EVFILT_WRITE, EV_ADD | EV_ENABLE | EV_CLEAR | EV_EOF, 0, 0, stream);
int status;
do {
status = kevent(janet_vm.kq, &kev, 1, NULL, 0, NULL);
status = kevent(janet_vm.kq, kevs, 2, NULL, 0, NULL);
} while (status == -1 && errno != EINTR);
if (status == -1) {
janet_panicv(janet_ev_lasterr());