mirror of
https://github.com/janet-lang/janet
synced 2025-01-14 09:25:41 +00:00
Fix incorrect use of EV_SET on pipes.
It would seem adding a read and a write event filter on a pipe which is unidirectional might just be a bad idea.
This commit is contained in:
parent
8f0641f36c
commit
c133443eb7
@ -1615,10 +1615,25 @@ JanetListenerState *janet_listen(JanetStream *stream, JanetListener behavior, in
|
|||||||
struct kevent kev[2];
|
struct kevent kev[2];
|
||||||
/* NOTE: NetBSD uses a different type for udata, might not work there or
|
/* NOTE: NetBSD uses a different type for udata, might not work there or
|
||||||
* may warn! */
|
* may warn! */
|
||||||
|
/* Disabled, may be incorrect
|
||||||
EV_SET(&kev[0], stream->handle, EVFILT_READ, EV_ADD | (state->stream->_mask & JANET_ASYNC_LISTEN_READ ? EV_ENABLE : EV_DISABLE), 0, 0, stream);
|
EV_SET(&kev[0], stream->handle, EVFILT_READ, EV_ADD | (state->stream->_mask & JANET_ASYNC_LISTEN_READ ? EV_ENABLE : EV_DISABLE), 0, 0, stream);
|
||||||
EV_SET(&kev[1], stream->handle, EVFILT_WRITE, EV_ADD | (state->stream->_mask & JANET_ASYNC_LISTEN_WRITE ? EV_ENABLE : EV_DISABLE), 0, 0, stream);
|
EV_SET(&kev[1], stream->handle, EVFILT_WRITE, EV_ADD | (state->stream->_mask & JANET_ASYNC_LISTEN_WRITE ? EV_ENABLE : EV_DISABLE), 0, 0, stream);
|
||||||
|
*/
|
||||||
|
|
||||||
|
int length = 0;
|
||||||
|
if (state->stream->_mask & JANET_ASYNC_LISTEN_READ) {
|
||||||
|
EV_SET(&kev[length], stream->handle, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, stream);
|
||||||
|
length++;
|
||||||
|
}
|
||||||
|
if (state->stream->_mask & JANET_ASYNC_LISTEN_WRITE) {
|
||||||
|
EV_SET(&kev[length], stream->handle, EVFILT_WRITE, EV_ADD | EV_ENABLE, 0, 0, stream);
|
||||||
|
length++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (length > 0) {
|
||||||
|
add_kqueue_events(kev, length);
|
||||||
|
}
|
||||||
|
|
||||||
add_kqueue_events(kev, 2);
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user