mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-15 20:48:00 +01:00
do a better job of rejecting messages that have strayed in from a different game.
This commit is contained in:
parent
5d64862ba6
commit
e61414933f
1 changed files with 76 additions and 68 deletions
|
@ -494,6 +494,7 @@ comms_getInitialAddr( CommsAddrRec* addr )
|
|||
#ifdef XWFEATURE_BLUETOOTH
|
||||
addr->conType = COMMS_CONN_BT; /* for temporary ease in debugging */
|
||||
#else
|
||||
addr->conType = COMMS_CONN_RELAY; /* for temporary ease in debugging */
|
||||
addr->u.ip_relay.ipAddr = 0L; /* force 'em to set it */
|
||||
addr->u.ip_relay.port = 10999;
|
||||
{
|
||||
|
@ -853,22 +854,26 @@ comms_checkIncomingStream( CommsCtxt* comms, XWStreamCtxt* stream,
|
|||
if ( stream_getSize( stream )
|
||||
>= sizeof(channelNo) + sizeof(msgID) + sizeof(lastMsgRcd) ) {
|
||||
|
||||
channelNo = stream_getU16( stream );
|
||||
XP_STATUSF( "read channelNo %d", channelNo );
|
||||
if ( channelNo == 0 || channelNo <= comms->nextChannelNo ) {
|
||||
|
||||
validMessage = XP_TRUE;
|
||||
|
||||
channelNo = stream_getU16( stream );
|
||||
msgID = stream_getU32( stream );
|
||||
lastMsgRcd = stream_getU32( stream );
|
||||
|
||||
XP_DEBUGF( "rcd: msg " XP_LD " on chnl %d", msgID, channelNo );
|
||||
XP_DEBUGF( "rcd: msg " XP_LD " on chnl %d", msgID,
|
||||
channelNo );
|
||||
|
||||
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
|
||||
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. */
|
||||
|
||||
if ( channelNo == 0 ) {
|
||||
XP_ASSERT( comms->isServer );
|
||||
|
@ -895,11 +900,13 @@ comms_checkIncomingStream( CommsCtxt* comms, XWStreamCtxt* stream,
|
|||
}
|
||||
#ifdef DEBUG
|
||||
if ( !!recs ) {
|
||||
XP_ASSERT( lastMsgRcd <= recs->nextMsgID );
|
||||
XP_ASSERT( lastMsgRcd < 0x0000FFFF );
|
||||
recs->lastACK = (XP_U16)lastMsgRcd;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if ( validMessage ) {
|
||||
XP_LOGF( "remembering senderID %x for channel %d",
|
||||
|
@ -925,6 +932,7 @@ comms_checkIncomingStream( CommsCtxt* comms, XWStreamCtxt* stream,
|
|||
} else {
|
||||
XP_LOGF( "%s: message too small", __FUNCTION__ );
|
||||
}
|
||||
LOG_RETURNF( "%d", (XP_U16)validMessage );
|
||||
return validMessage;
|
||||
} /* comms_checkIncomingStream */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue