mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
don't try to read from socket after it's been closed
This commit is contained in:
parent
e6248210a5
commit
4b5af7ebdf
1 changed files with 32 additions and 29 deletions
|
@ -1055,6 +1055,7 @@ linux_close_socket( CommonGlobals* cGlobals )
|
|||
int
|
||||
blocking_read( int fd, unsigned char* buf, const int len )
|
||||
{
|
||||
assert( -1 != fd );
|
||||
int nRead = 0;
|
||||
while ( nRead < len ) {
|
||||
ssize_t siz = read( fd, buf + nRead, len - nRead );
|
||||
|
@ -1073,9 +1074,11 @@ blocking_read( int fd, unsigned char* buf, const int len )
|
|||
int
|
||||
linux_relay_receive( CommonGlobals* cGlobals, unsigned char* buf, int bufSize )
|
||||
{
|
||||
ssize_t nRead = -1;
|
||||
int sock = cGlobals->socket;
|
||||
if ( -1 != sock ) {
|
||||
unsigned short tmp;
|
||||
ssize_t nRead = blocking_read( sock, (unsigned char*)&tmp, sizeof(tmp) );
|
||||
nRead = blocking_read( sock, (unsigned char*)&tmp, sizeof(tmp) );
|
||||
if ( nRead != 2 ) {
|
||||
nRead = -1;
|
||||
} else {
|
||||
|
@ -1113,7 +1116,7 @@ linux_relay_receive( CommonGlobals* cGlobals, unsigned char* buf, int bufSize )
|
|||
linux_close_socket( cGlobals );
|
||||
comms_transportFailed( cGlobals->game.comms );
|
||||
}
|
||||
|
||||
}
|
||||
XP_LOGF( "%s=>%d", __func__, nRead );
|
||||
return nRead;
|
||||
} /* linux_relay_receive */
|
||||
|
|
Loading…
Reference in a new issue