test for duplicate initial client message and if so drop it; add const keyword; add assertion in addr comparion in attempt to learn why duplicates are getting through.

This commit is contained in:
ehouse 2007-12-31 20:00:13 +00:00
parent 4074417b33
commit 40f7295802
4 changed files with 110 additions and 99 deletions

View file

@ -1014,9 +1014,13 @@ preProcess( CommsCtxt* comms, XWStreamCtxt* stream,
static AddressRecord*
addrToRecord( CommsCtxt* comms, const CommsAddrRec* addr )
{
CommsConnType conType = addr->conType;
CommsConnType conType;
AddressRecord* rec;
XP_Bool matched = XP_FALSE;
XP_ASSERT( !!addr );
conType = addr->conType;
for ( rec = comms->recs; !!rec; rec = rec->next ) {
XP_ASSERT( conType == rec->addr.conType );
switch( conType ) {
@ -1039,7 +1043,9 @@ addrToRecord( CommsCtxt* comms, const CommsAddrRec* addr )
}
break;
case COMMS_CONN_IR: /* no way to test */
break;
default:
XP_ASSERT(0);
break;
}
if ( matched ) {

View file

@ -315,10 +315,10 @@ gi_disposePlayerInfo( MPFORMAL CurGameInfo* gi )
} /* gi_disposePlayerInfo */
void
gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGI )
gi_copy( MPFORMAL CurGameInfo* destGI, const CurGameInfo* srcGI )
{
XP_U16 nPlayers, i;
LocalPlayer* srcPl;
const LocalPlayer* srcPl;
LocalPlayer* destPl;
replaceStringIfDifferent( mpool, &destGI->dictName,

View file

@ -99,7 +99,7 @@ void gi_initPlayerInfo( MPFORMAL CurGameInfo* gi,
void gi_disposePlayerInfo( MPFORMAL CurGameInfo* gi );
void gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi );
void gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi );
void gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGi );
void gi_copy( MPFORMAL CurGameInfo* destGI, const CurGameInfo* srcGi );
XP_U16 gi_countLocalHumans( const CurGameInfo* gi );
XP_Bool player_hasPasswd( LocalPlayer* player );

View file

@ -940,6 +940,12 @@ clearLocalRobots( ServerCtxt* server )
static XP_Bool
client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
{
XP_Bool accepted = 0 == server->nv.addresses[0].channelNo;
/* We should never get this message a second time, but very rarely we do.
Drop it in that case. */
XP_ASSERT( accepted );
if ( accepted ) {
DictionaryCtxt* newDict;
DictionaryCtxt* curDict;
XP_U16 nPlayers, nCols;
@ -980,7 +986,6 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
channelNo = stream_getAddress( stream );
XP_ASSERT( channelNo != 0 );
XP_ASSERT( server->nv.addresses[0].channelNo == 0 );
server->nv.addresses[0].channelNo = channelNo;
/* PENDING init's a bit harsh for setting the size */
@ -1035,8 +1040,8 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
/* Give board a chance to redraw self with the full compliment of known
players */
setTurn( server, 0 );
return XP_TRUE;
}
return accepted;
} /* client_readInitialMessage */
#endif