Skip to content

Commit

Permalink
select: propagate an error of sockets
Browse files Browse the repository at this point in the history
    modified:   network/select.c
  • Loading branch information
komh committed Jan 14, 2022
1 parent 62e37e8 commit c54f71f
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions network/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,27 @@ typedef struct WAITSOCKSARGS
PSELECTPARM parm;
struct timeval *timeout;
HEV hev;
int err;
} WAITSOCKSARGS, *PWAITSOCKSARGS;

static void waitsocks( void *arg )
{
WAITSOCKSARGS wsa = *( PWAITSOCKSARGS )arg;
PWAITSOCKSARGS wsa = arg;
int n;

n = _std_select( wsa.parm->nmaxfds, &wsa.parm->fdset[ FDSET_READ ],
&wsa.parm->fdset[ FDSET_WRITE ],
&wsa.parm->fdset[ FDSET_EXCEPT ], wsa.timeout );
n = _std_select( wsa->parm->nmaxfds,
&wsa->parm->fdset[ FDSET_READ ],
&wsa->parm->fdset[ FDSET_WRITE ],
&wsa->parm->fdset[ FDSET_EXCEPT ],
wsa->timeout );

if( n > 0 )
DosPostEventSem( wsa.hev );
if( n != 0 )
{
if( n == -1 )
wsa->err = errno;

DosPostEventSem( wsa->hev );
}
}

int select( int nfds, fd_set *rdset, fd_set *wrset, fd_set *exset,
Expand Down Expand Up @@ -403,6 +411,7 @@ int select( int nfds, fd_set *rdset, fd_set *wrset, fd_set *exset,
PSELECTPARM parm = &parms[ ST_PIPE ];
HMUX hmux;
SEMRECORD sr;
WAITSOCKSARGS wsa;
TID tidSock = -1;
ULONG ulTimeout;
ULONG ulUser;
Expand Down Expand Up @@ -449,7 +458,6 @@ int select( int nfds, fd_set *rdset, fd_set *wrset, fd_set *exset,
if( hevSock != NULLHANDLE )
{
PSELECTPARM parmsock = &parms[ ST_SOCKET ];
WAITSOCKSARGS wsa;

sr.hsemCur = ( HSEM )hevSock;
sr.ulUser = ( ULONG )hevSock;
Expand All @@ -469,6 +477,7 @@ int select( int nfds, fd_set *rdset, fd_set *wrset, fd_set *exset,
wsa.parm = parmsock;
wsa.timeout = timeout;
wsa.hev = hevSock;
wsa.err = 0;

/* no pipes ? */
if( nrpipesems == 0 && nwpipesems == 0 )
Expand Down Expand Up @@ -508,11 +517,6 @@ int select( int nfds, fd_set *rdset, fd_set *wrset, fd_set *exset,
break;

case 0:
checkpipesems( nrpipesems, rpipesems,
&parm->fdset[ FDSET_READ ], 0 );
checkpipesems( nwpipesems, wpipesems,
&parm->fdset[ FDSET_WRITE ], 0 );

if( hevSock != NULLHANDLE )
{
if( DosWaitEventSem( hevSock, SEM_IMMEDIATE_RETURN ) != 0 )
Expand All @@ -527,10 +531,21 @@ int select( int nfds, fd_set *rdset, fd_set *wrset, fd_set *exset,
/* unblock on select() */
so_cancel( cancelsock );
}
else if( wsa.err != 0 )
err = wsa.err;
#if 0
DosWaitThread( &tidSock, DCWW_WAIT );
#endif
}

if( err == 0 )
{
checkpipesems( nrpipesems, rpipesems,
&parm->fdset[ FDSET_READ ], 0 );
checkpipesems( nwpipesems, wpipesems,
&parm->fdset[ FDSET_WRITE ], 0 );
}

break;

default:
Expand Down

0 comments on commit c54f71f

Please sign in to comment.