fix logging: calling read(), not recv()

This commit is contained in:
Andy2 2011-06-24 18:28:18 -07:00
parent 9ff149fe2d
commit e44ed96691

View file

@ -657,6 +657,8 @@ blocking_read( int fd, unsigned char* buf, int len )
while ( nRead < len ) { while ( nRead < len ) {
ssize_t siz = read( fd, buf + nRead, len - nRead ); ssize_t siz = read( fd, buf + nRead, len - nRead );
if ( siz <= 0 ) { if ( siz <= 0 ) {
XP_LOGF( "read => %d, errno=%d (\"%s\")", nRead,
errno, strerror(errno) );
nRead = -1; nRead = -1;
break; break;
} }
@ -673,7 +675,6 @@ linux_relay_receive( CommonGlobals* cGlobals, unsigned char* buf, int bufSize )
unsigned short packetSize; unsigned short packetSize;
ssize_t nRead = blocking_read( sock, (unsigned char*)&tmp, sizeof(tmp) ); ssize_t nRead = blocking_read( sock, (unsigned char*)&tmp, sizeof(tmp) );
if ( nRead != 2 ) { if ( nRead != 2 ) {
XP_LOGF( "recv => %d, errno=%d (\"%s\")", nRead, errno, strerror(errno) );
linux_close_socket( cGlobals ); linux_close_socket( cGlobals );
comms_transportFailed( cGlobals->game.comms ); comms_transportFailed( cGlobals->game.comms );
nRead = -1; nRead = -1;
@ -681,11 +682,7 @@ linux_relay_receive( CommonGlobals* cGlobals, unsigned char* buf, int bufSize )
packetSize = ntohs( tmp ); packetSize = ntohs( tmp );
assert( packetSize <= bufSize ); assert( packetSize <= bufSize );
nRead = blocking_read( sock, buf, packetSize ); nRead = blocking_read( sock, buf, packetSize );
if ( nRead < 0 ) { if ( nRead == packetSize ) {
XP_WARNF( "%s: errno=%d (\"%s\")\n", __func__, errno,
strerror(errno) );
}
LaunchParams* params = cGlobals->params; LaunchParams* params = cGlobals->params;
++params->nPacketsRcvd; ++params->nPacketsRcvd;
if ( params->dropNthRcvd == 0 ) { if ( params->dropNthRcvd == 0 ) {
@ -705,6 +702,7 @@ linux_relay_receive( CommonGlobals* cGlobals, unsigned char* buf, int bufSize )
} }
} }
} }
}
return nRead; return nRead;
} /* linux_relay_receive */ } /* linux_relay_receive */
#endif /* XWFEATURE_RELAY */ #endif /* XWFEATURE_RELAY */