don't stop processing message referring to multiple games as soon as

one of them can't be found.
This commit is contained in:
Eric House 2013-02-08 20:58:09 -08:00
parent 6a1b86380e
commit eafac8724e

View file

@ -1059,12 +1059,12 @@ handlePutMessage( SafeCref& scr, HostID hid, const AddrInfo* addr,
// sanity check that cmd and hostids are there // sanity check that cmd and hostids are there
if ( getNetByte( bufp, end, &cmd ) if ( getNetByte( bufp, end, &cmd )
&& getNetByte( bufp, end, &src ) && getNetByte( bufp, end, &src )
&& getNetByte( bufp, end, &dest ) && getNetByte( bufp, end, &dest ) ) {
&& ( cmd == XWRELAY_MSG_TORELAY_NOCONN ) success = true; // meaning, buffer content looks ok
&& ( hid == dest ) ) {
scr.PutMsg( src, addr, dest, start, len );
*bufp = start + len; *bufp = start + len;
success = true; if ( ( cmd == XWRELAY_MSG_TORELAY_NOCONN ) && ( hid == dest ) ) {
scr.PutMsg( src, addr, dest, start, len );
}
} }
logf( XW_LOGINFO, "%s()=>%d", __func__, success ); logf( XW_LOGINFO, "%s()=>%d", __func__, success );
return success; return success;
@ -1099,12 +1099,12 @@ handleProxyMsgs( int sock, const AddrInfo* addr, const unsigned char* bufp,
unsigned short nMsgs; unsigned short nMsgs;
if ( getNetShort( &bufp, end, &nMsgs ) ) { if ( getNetShort( &bufp, end, &nMsgs ) ) {
SafeCref scr( connName ); SafeCref scr( connName );
while ( scr.IsValid() && nMsgs-- > 0 ) { while ( nMsgs-- > 0 ) {
unsigned short len; unsigned short len;
if ( getNetShort( &bufp, end, &len ) ) { if ( getNetShort( &bufp, end, &len ) ) {
if ( handlePutMessage( scr, hid, addr, len, &bufp, end ) ) { if ( handlePutMessage( scr, hid, addr, len, &bufp, end ) ) {
continue; continue;
} }
} }
break; break;
} }
@ -1128,16 +1128,13 @@ game_thread_proc( UdpThreadClosure* utc )
static void static void
proxy_thread_proc( UdpThreadClosure* utc ) proxy_thread_proc( UdpThreadClosure* utc )
{ {
int len = utc->len(); const int len = utc->len();
const AddrInfo* addr = utc->addr(); const AddrInfo* addr = utc->addr();
const unsigned char* buf = utc->buf();
logf( XW_LOGINFO, "%s called", __func__ );
logf( XW_LOGVERBOSE0, "%s()", __func__ );
if ( len > 0 ) { if ( len > 0 ) {
assert( addr->isTCP() ); assert( addr->isTCP() );
int socket = addr->socket(); int socket = addr->socket();
const unsigned char* bufp = buf; const unsigned char* bufp = utc->buf();
const unsigned char* end = bufp + len; const unsigned char* end = bufp + len;
if ( (0 == *bufp++) ) { /* protocol */ if ( (0 == *bufp++) ) { /* protocol */
XWPRXYCMD cmd = (XWPRXYCMD)*bufp++; XWPRXYCMD cmd = (XWPRXYCMD)*bufp++;
@ -1173,7 +1170,7 @@ proxy_thread_proc( UdpThreadClosure* utc )
handleProxyMsgs( socket, addr, bufp, end ); handleProxyMsgs( socket, addr, bufp, end );
break; break;
case PRX_DEVICE_GONE: case PRX_DEVICE_GONE: {
logf( XW_LOGINFO, "%s: got PRX_DEVICE_GONE", __func__ ); logf( XW_LOGINFO, "%s: got PRX_DEVICE_GONE", __func__ );
if ( len >= 2 ) { if ( len >= 2 ) {
unsigned short nameCount; unsigned short nameCount;
@ -1196,9 +1193,10 @@ proxy_thread_proc( UdpThreadClosure* utc )
} }
} }
} }
len = 0; /* return a 0-length message */ int olen = 0; /* return a 0-length message */
write( socket, &len, sizeof(len) ); write( socket, &olen, sizeof(olen) );
break; /* PRX_DEVICE_GONE */ break; /* PRX_DEVICE_GONE */
}
default: default:
logf( XW_LOGERROR, "unexpected command %d", __func__, cmd ); logf( XW_LOGERROR, "unexpected command %d", __func__, cmd );
break; break;
@ -1206,7 +1204,7 @@ proxy_thread_proc( UdpThreadClosure* utc )
} }
} }
XWThreadPool::GetTPool()->CloseSocket( addr ); XWThreadPool::GetTPool()->CloseSocket( addr );
} } // proxy_thread_proc
static short static short
addRegID( unsigned char* ptr, DevIDRelay relayID ) addRegID( unsigned char* ptr, DevIDRelay relayID )