Skip to content
Snippets Groups Projects
Commit 0f00cbea authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix multi-array version of socket_select() when using poll()

Previously, when multiple lists were passed, the "write" parameter
(which can't be changed) was applied to all sockets.  This means
they would always all be poll()ed for read, then checked for the
appropriate flag (read/write/priority)... which effectively meant
that only the first (read) array would work.
parent e67f51d0
No related branches found
No related tags found
No related merge requests found
Pipeline #6771 passed
......@@ -3974,21 +3974,25 @@ js_socket_select(JSContext *cx, uintN argc, jsval *arglist)
nfds = 0;
for (j = 0; j < inarray_cnt; j++) {
if (limit[j] > 0) {
switch (j) {
case 0:
events = POLLIN;
break;
case 1:
events = POLLOUT;
break;
case 2:
events = POLLPRI;
break;
if (inarray_cnt == 1)
events = poll_for_write ? POLLOUT : POLLIN;
else {
switch (j) {
case 0:
events = POLLIN;
break;
case 1:
events = POLLOUT;
break;
case 2:
events = POLLPRI;
break;
}
}
for (i = 0; i < limit[j]; i++) {
if(!JS_GetElement(cx, inarray[j], i, &val))
break;
nfds += js_socket_add(cx, val, &fds[nfds], poll_for_write ? POLLOUT : POLLIN);
nfds += js_socket_add(cx, val, &fds[nfds], events);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment