Skip to content

Commit 1df521a

Browse files
committed
Fix cnex net.select() function
1 parent 2057bc4 commit 1df521a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

exec/cnex/lib/net.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ void net_socket_send(TExecutor *exec)
322322
void net_socket_select(TExecutor *exec)
323323
{
324324
Number timeout_seconds = top(exec->stack)->number; pop(exec->stack);
325-
Cell *error = peek(exec->stack, 0)->address;
326-
Cell *write = peek(exec->stack, 1)->address;
327-
Cell *read = peek(exec->stack, 2)->address;
325+
Cell *error = top(exec->stack)->address; pop(exec->stack);
326+
Cell *write = top(exec->stack)->address; pop(exec->stack);
327+
Cell *read = top(exec->stack)->address; pop(exec->stack);
328328

329329
fd_set rfds, wfds, efds;
330330
FD_ZERO(&rfds);
@@ -410,7 +410,7 @@ void net_socket_select(TExecutor *exec)
410410
for (size_t i = 0; i < write->array->size; ) {
411411
SOCKET *ps = check_socket(exec, write->array->data[i].array->data[0].object);
412412
SOCKET fd = *ps;
413-
if (FD_ISSET(fd, &rfds)) {
413+
if (FD_ISSET(fd, &wfds)) {
414414
++i;
415415
} else {
416416
array_removeItem(write->array, i);
@@ -420,7 +420,7 @@ void net_socket_select(TExecutor *exec)
420420
for (size_t i = 0; i < error->array->size; ) {
421421
SOCKET *ps = check_socket(exec, error->array->data[i].array->data[0].object);
422422
SOCKET fd = *ps;
423-
if (FD_ISSET(fd, &rfds)) {
423+
if (FD_ISSET(fd, &efds)) {
424424
++i;
425425
} else {
426426
array_removeItem(error->array, i);

0 commit comments

Comments
 (0)