remove timer assert; log socket errors

This commit is contained in:
ehouse 2009-08-21 12:15:40 +00:00
parent d9c3da1da7
commit 537de614b9
2 changed files with 75 additions and 72 deletions

View file

@ -942,6 +942,7 @@ figureTimeout( CursesAppGlobals* globals )
# define figureTimeout(g) INFINITE_TIMEOUT
#endif
#ifdef XWFEATURE_RELAY
static void
fireCursesTimer( CursesAppGlobals* globals )
{
@ -960,12 +961,17 @@ fireCursesTimer( CursesAppGlobals* globals )
}
if ( !!smallestTip ) {
XP_ASSERT( util_getCurSeconds( globals->cGlobals.params->util )
>= smallestTip->when );
XP_U32 now = util_getCurSeconds( globals->cGlobals.params->util ) ;
if ( now >= smallestTip->when ) {
linuxFireTimer( &globals->cGlobals,
smallestTip - globals->cGlobals.timerInfo );
} else {
XP_LOGF( "skipping timer: now (%ld) < when (%ld)",
now, smallestTip->when );
}
}
}
} /* fireCursesTimer */
#endif
/*
* Ok, so this doesn't block yet....
@ -1001,7 +1007,6 @@ blocking_gotEvent( CursesAppGlobals* globals, int* ch )
if ( (globals->fdArray[FD_TIMEEVT].revents & POLLIN) != 0 ) {
char ch;
/* XP_DEBUGF( "curses got a USER EVENT\n" ); */
if ( 1 != read(globals->fdArray[FD_TIMEEVT].fd, &ch, 1 ) ) {
XP_ASSERT(0);
}
@ -1009,8 +1014,13 @@ blocking_gotEvent( CursesAppGlobals* globals, int* ch )
fdIndex = FD_FIRSTSOCKET;
if ( numEvents > 0 &&
(globals->fdArray[fdIndex].revents & POLLIN) != 0 ) {
if ( numEvents > 0 ) {
if ( (globals->fdArray[fdIndex].revents & ~POLLIN ) ) {
XP_LOGF( "some other events set on socket %d",
globals->fdArray[fdIndex].fd );
}
if ( (globals->fdArray[fdIndex].revents & POLLIN) != 0 ) {
--numEvents;
@ -1055,23 +1065,15 @@ blocking_gotEvent( CursesAppGlobals* globals, int* ch )
if ( nBytes != -1 ) {
XWStreamCtxt* inboundS;
/* struct sockaddr_in addr_sock = {0}; */
redraw = XP_FALSE;
XP_STATUSF( "linuxReceive=>%d", nBytes );
inboundS = stream_from_msgbuf( &globals->cGlobals,
buf, nBytes );
if ( !!inboundS ) {
/* addrRec.u.ip_relay.ipAddr = */
/* ntohl(addr_sock.sin_addr.s_addr); */
/* XP_LOGF( "captured incoming ip address: 0x%lx", */
/* addrRec.u.ip_relay.ipAddr ); */
if ( comms_checkIncomingStream(
globals->cGlobals.game.comms,
inboundS, addrp ) ) {
/* XP_LOGF( "comms read port: %d", */
/* addrRec.u.ip_relay.port ); */
redraw = server_receiveMessage(
globals->cGlobals.game.server, inboundS );
}
@ -1092,6 +1094,7 @@ blocking_gotEvent( CursesAppGlobals* globals, int* ch )
}
++fdIndex;
}
}
redraw = server_do( globals->cGlobals.game.server ) || redraw;
if ( redraw ) {

View file

@ -512,12 +512,12 @@ linux_relay_receive( CommonGlobals* cGlobals, unsigned char* buf, int bufSize )
assert( packetSize <= bufSize );
nRead = recv( sock, buf, packetSize, 0 );
if ( nRead < 0 ) {
XP_WARNF( "linuxReceive: errno=%d (\"%s\")\n", errno,
XP_WARNF( "%s: errno=%d (\"%s\")\n", __func__, errno,
strerror(errno) );
}
}
return nRead;
} /* linuxReceive */
} /* linux_relay_receive */
#endif /* XWFEATURE_RELAY */
/* Create a stream for the incoming message buffer, and read in any