mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
fix logging: calling read(), not recv()
This commit is contained in:
parent
9ff149fe2d
commit
e44ed96691
1 changed files with 20 additions and 22 deletions
|
@ -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,27 +682,24 @@ 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,
|
LaunchParams* params = cGlobals->params;
|
||||||
strerror(errno) );
|
++params->nPacketsRcvd;
|
||||||
}
|
if ( params->dropNthRcvd == 0 ) {
|
||||||
|
/* do nothing */
|
||||||
LaunchParams* params = cGlobals->params;
|
} else if ( params->dropNthRcvd > 0 ) {
|
||||||
++params->nPacketsRcvd;
|
if ( params->nPacketsRcvd == params->dropNthRcvd ) {
|
||||||
if ( params->dropNthRcvd == 0 ) {
|
XP_LOGF( "%s: dropping %dth packet per --drop-nth-packet",
|
||||||
/* do nothing */
|
__func__, params->nPacketsRcvd );
|
||||||
} else if ( params->dropNthRcvd > 0 ) {
|
nRead = -1;
|
||||||
if ( params->nPacketsRcvd == params->dropNthRcvd ) {
|
}
|
||||||
XP_LOGF( "%s: dropping %dth packet per --drop-nth-packet",
|
} else {
|
||||||
__func__, params->nPacketsRcvd );
|
if ( 0 == XP_RANDOM() % -params->dropNthRcvd ) {
|
||||||
nRead = -1;
|
XP_LOGF( "%s: RANDOMLY dropping %dth packet "
|
||||||
}
|
"per --drop-nth-packet",
|
||||||
} else {
|
__func__, params->nPacketsRcvd );
|
||||||
if ( 0 == XP_RANDOM() % -params->dropNthRcvd ) {
|
nRead = -1;
|
||||||
XP_LOGF( "%s: RANDOMLY dropping %dth packet "
|
}
|
||||||
"per --drop-nth-packet",
|
|
||||||
__func__, params->nPacketsRcvd );
|
|
||||||
nRead = -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue