Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support events is zero for uv_poll #702

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions src/poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static int luv_new_socket_poll(lua_State* L) {
}

static const char *const luv_pollevents[] = {
"r", "w", "rw",
"", "r", "w", "rw",
#if LUV_UV_VERSION_GEQ(1, 9, 0)
"d", "rd", "wd", "rwd",
#endif
Expand Down Expand Up @@ -102,24 +102,25 @@ static int luv_poll_start(lua_State* L) {
uv_poll_t* handle = luv_check_poll(L, 1);
int events, ret;
switch (luaL_checkoption(L, 2, "rw", luv_pollevents)) {
case 0: events = UV_READABLE; break;
case 1: events = UV_WRITABLE; break;
case 2: events = UV_READABLE | UV_WRITABLE; break;
case 0: events = 0; break;
case 1: events = UV_READABLE; break;
case 2: events = UV_WRITABLE; break;
case 3: events = UV_READABLE | UV_WRITABLE; break;
#if LUV_UV_VERSION_GEQ(1, 9, 0)
case 3: events = UV_DISCONNECT; break;
case 4: events = UV_READABLE|UV_DISCONNECT; break;
case 5: events = UV_WRITABLE|UV_DISCONNECT; break;
case 6: events = UV_READABLE|UV_WRITABLE|UV_DISCONNECT; break;
case 4: events = UV_DISCONNECT; break;
case 5: events = UV_READABLE|UV_DISCONNECT; break;
case 6: events = UV_WRITABLE|UV_DISCONNECT; break;
case 7: events = UV_READABLE|UV_WRITABLE|UV_DISCONNECT; break;
#endif
#if LUV_UV_VERSION_GEQ(1, 14, 0)
case 7: events = UV_PRIORITIZED; break;
case 8: events = UV_READABLE|UV_PRIORITIZED; break;
case 9: events = UV_WRITABLE|UV_PRIORITIZED; break;
case 10: events = UV_READABLE|UV_WRITABLE|UV_PRIORITIZED; break;
case 11: events = UV_DISCONNECT|UV_PRIORITIZED; break;
case 12: events = UV_READABLE|UV_DISCONNECT|UV_PRIORITIZED; break;
case 13: events = UV_WRITABLE|UV_DISCONNECT|UV_PRIORITIZED; break;
case 14: events = UV_READABLE|UV_WRITABLE|UV_DISCONNECT|UV_PRIORITIZED; break;
case 8: events = UV_PRIORITIZED; break;
case 9: events = UV_READABLE|UV_PRIORITIZED; break;
case 10: events = UV_WRITABLE|UV_PRIORITIZED; break;
case 11: events = UV_READABLE|UV_WRITABLE|UV_PRIORITIZED; break;
case 12: events = UV_DISCONNECT|UV_PRIORITIZED; break;
case 13: events = UV_READABLE|UV_DISCONNECT|UV_PRIORITIZED; break;
case 14: events = UV_WRITABLE|UV_DISCONNECT|UV_PRIORITIZED; break;
case 15: events = UV_READABLE|UV_WRITABLE|UV_DISCONNECT|UV_PRIORITIZED; break;
#endif
default: events = 0; /* unreachable */
}
Expand Down
Loading