Skip to content

Commit

Permalink
select: fix time-limit timeout for a pipe and a socket test failure
Browse files Browse the repository at this point in the history
On some situtation, this test fails. For example,

    select-1 2>&1 | cat

This is because events are not cleared correctly after select() in
waitsocks(). So so_cancel() should be called first before clearing socket
events.

And ensure that waitsocks() thread ends. Otherwise, the thread may
be running after select() returns. This may lead to unexpected
situtations. For example, consecutive select() calls may be affected
by a previous select() call.

    modified:   network/select.c
  • Loading branch information
komh committed Oct 8, 2023
1 parent 8c56ede commit afffa2a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions network/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,19 +525,18 @@ int select( int nfds, fd_set *rdset, fd_set *wrset, fd_set *exset,
{
PSELECTPARM parmsock = &parms[ ST_SOCKET ];

/* unblock on select() */
so_cancel( cancelsock );

/* clear events */
FD_ZERO( &parmsock->fdset[ FDSET_READ ]);
FD_ZERO( &parmsock->fdset[ FDSET_WRITE ]);
FD_ZERO( &parmsock->fdset[ FDSET_EXCEPT ]);

/* unblock on select() */
so_cancel( cancelsock );
}
else if( wsa.err != 0 )
err = wsa.err;
#if 0

DosWaitThread( &tidSock, DCWW_WAIT );
#endif
}

if( err == 0 )
Expand Down

0 comments on commit afffa2a

Please sign in to comment.