remove over-agressive attempt to detect out-of-order messages that was

breaking IR comms.
This commit is contained in:
ehouse 2006-09-17 05:06:46 +00:00
parent d03ef80b3e
commit 8667bb77bf

View file

@ -608,9 +608,8 @@ printQueue( CommsCtxt* comms )
i+1, elem->channelNo, elem->msgID ); i+1, elem->channelNo, elem->msgID );
} }
} }
#else
#define printQueue(foo)
#endif #endif
/* We've received on some channel a message with a certain ID. This means /* We've received on some channel a message with a certain ID. This means
* that all messages sent on that channel with lower IDs have been received * that all messages sent on that channel with lower IDs have been received
* and can be removed from our queue. * and can be removed from our queue.
@ -662,11 +661,13 @@ removeFromQueue( CommsCtxt* comms, XP_PlayerAddr channelNo, MsgID msgID )
} }
} }
} }
XP_STATUSF( "removeFromQueue: queueLen now %d", comms->queueLen ); XP_STATUSF( "%s: queueLen now %d", __FUNCTION__, comms->queueLen );
XP_ASSERT( comms->queueLen > 0 || comms->msgQueueHead == NULL ); XP_ASSERT( comms->queueLen > 0 || comms->msgQueueHead == NULL );
#ifdef DEBUG
printQueue( comms ); printQueue( comms );
#endif
} /* removeFromQueue */ } /* removeFromQueue */
static XP_S16 static XP_S16
@ -856,56 +857,60 @@ comms_checkIncomingStream( CommsCtxt* comms, XWStreamCtxt* stream,
channelNo = stream_getU16( stream ); channelNo = stream_getU16( stream );
XP_STATUSF( "read channelNo %d", channelNo ); XP_STATUSF( "read channelNo %d", channelNo );
if ( channelNo == 0 || channelNo <= comms->nextChannelNo ) {
validMessage = XP_TRUE; msgID = stream_getU32( stream );
lastMsgRcd = stream_getU32( stream );
msgID = stream_getU32( stream ); XP_DEBUGF( "rcd: msg " XP_LD " on chnl %d", msgID,
lastMsgRcd = stream_getU32( stream ); channelNo );
XP_DEBUGF( "rcd: msg " XP_LD " on chnl %d", msgID, removeFromQueue( comms, channelNo, lastMsgRcd );
channelNo ); validMessage = XP_TRUE;
removeFromQueue( comms, channelNo, lastMsgRcd ); /* Problem: need to detect duplicate messages even before
the server's had a chance to assign channels.
Solution, which is a hack: since hostID does the same
thing, use it in the relay case. But in the relay-less
case, which still needs to work, do assign channels.
The dup message problem is far less common there. */
/* Problem: need to detect duplicate messages even before if ( channelNo == 0 ) {
the server's had a chance to assign channels. XP_ASSERT( comms->isServer );
Solution, which is a hack: since hostID does the same if ( usingRelay ) {
thing, use it in the relay case. But in the relay-less XP_ASSERT( senderID != 0 );
case, which still needs to work, do assign channels. channelNo = senderID;
The dup message problem is far less common there. */ } else {
XP_ASSERT( msgID == 0 );
if ( channelNo == 0 ) { channelNo = ++comms->nextChannelNo;
XP_ASSERT( comms->isServer ); XP_LOGF( "%s: incrementled nextChannelNo to %d",
if ( usingRelay ) { __FUNCTION__, comms->nextChannelNo );
XP_ASSERT( senderID != 0 ); channelWas0 = XP_TRUE;
channelNo = senderID; }
} else { XP_STATUSF( "assigning channelNo=%d", channelNo );
XP_ASSERT( msgID == 0 ); }
channelNo = ++comms->nextChannelNo; if ( usingRelay || !channelWas0 ) {
channelWas0 = XP_TRUE; recs = getRecordFor( comms, channelNo );
} /* messageID for an incoming message should be one
XP_STATUSF( "assigning channelNo=%d", channelNo ); * greater than the id most recently used for that
} * channel. */
if ( usingRelay || !channelWas0 ) { if ( !!recs ) {
recs = getRecordFor( comms, channelNo ); if ( msgID != recs->lastMsgReceived + 1 ) {
/* messageID for an incomming message should be one
* greater than the id most recently used for that
* channel. */
if ( !!recs && (msgID != recs->lastMsgReceived + 1) ) {
XP_DEBUGF( "on channel %d, old msgID " XP_LD XP_DEBUGF( "on channel %d, old msgID " XP_LD
" (next should be " XP_LD ")", channelNo, " (next should be " XP_LD ")", channelNo,
msgID, recs->lastMsgReceived+1 ); msgID, recs->lastMsgReceived+1 );
validMessage = XP_FALSE; validMessage = XP_FALSE;
} }
#ifdef DEBUG } else if ( msgID > 1 ) {
if ( !!recs ) { XP_ASSERT( 0 );
XP_ASSERT( lastMsgRcd <= recs->nextMsgID ); validMessage = XP_FALSE;
XP_ASSERT( lastMsgRcd < 0x0000FFFF );
recs->lastACK = (XP_U16)lastMsgRcd;
}
#endif
} }
#ifdef DEBUG
if ( !!recs ) {
XP_ASSERT( lastMsgRcd <= recs->nextMsgID );
XP_ASSERT( lastMsgRcd < 0x0000FFFF );
recs->lastACK = (XP_U16)lastMsgRcd;
}
#endif
} }
if ( validMessage ) { if ( validMessage ) {