Skip to content

Commit

Permalink
Fix cnex net.select() function
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlarryf authored and ghewgill committed Apr 23, 2024
1 parent 9ae5c25 commit b7b6472
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions exec/cnex/lib/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ void net_socket_send(TExecutor *exec)
void net_socket_select(TExecutor *exec)
{
Number timeout_seconds = top(exec->stack)->number; pop(exec->stack);
Cell *error = peek(exec->stack, 0)->address;
Cell *write = peek(exec->stack, 1)->address;
Cell *read = peek(exec->stack, 2)->address;
Cell *error = top(exec->stack)->address; pop(exec->stack);
Cell *write = top(exec->stack)->address; pop(exec->stack);
Cell *read = top(exec->stack)->address; pop(exec->stack);

fd_set rfds, wfds, efds;
FD_ZERO(&rfds);
Expand Down Expand Up @@ -410,7 +410,7 @@ void net_socket_select(TExecutor *exec)
for (size_t i = 0; i < write->array->size; ) {
SOCKET *ps = check_socket(exec, write->array->data[i].array->data[0].object);
SOCKET fd = *ps;
if (FD_ISSET(fd, &rfds)) {
if (FD_ISSET(fd, &wfds)) {
++i;
} else {
array_removeItem(write->array, i);
Expand All @@ -420,7 +420,7 @@ void net_socket_select(TExecutor *exec)
for (size_t i = 0; i < error->array->size; ) {
SOCKET *ps = check_socket(exec, error->array->data[i].array->data[0].object);
SOCKET fd = *ps;
if (FD_ISSET(fd, &rfds)) {
if (FD_ISSET(fd, &efds)) {
++i;
} else {
array_removeItem(error->array, i);
Expand Down

0 comments on commit b7b6472

Please sign in to comment.