From 3648c22bd452e8ac13b0083142f8d57ec579f8f1 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 18 Oct 2010 20:17:44 -0700 Subject: [PATCH 1/3] fix long-standing bug where initial messages were not getting deleted and multiplying; log md5 sums of messages in debug build. --- xwords4/common/comms.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index 665f88de1..8d36bdeaa 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -54,6 +54,9 @@ typedef struct MsgQueueElem { XP_PlayerAddr channelNo; XP_U16 sendCount; /* how many times sent? */ MsgID msgID; /* saved for ease of deletion */ +#ifdef DEBUG + gchar* checksum; +#endif } MsgQueueElem; typedef struct AddressRecord { @@ -550,7 +553,10 @@ comms_makeFromStream( MPFORMAL XWStreamCtxt* stream, XW_UtilCtxt* util, msg->len = stream_getU16( stream ); msg->msg = (XP_U8*)XP_MALLOC( mpool, msg->len ); stream_getBytes( stream, msg->msg, msg->len ); - +#ifdef DEBUG + msg->checksum = g_compute_checksum_for_data( G_CHECKSUM_MD5, + msg->msg, msg->len ); +#endif msg->next = (MsgQueueElem*)NULL; *prevsQueueNext = comms->msgQueueTail = msg; comms->msgQueueTail = msg; @@ -880,6 +886,11 @@ makeElemWithID( CommsCtxt* comms, MsgID msgID, AddressRecord* rec, stream_getBytes( stream, newMsgElem->msg + headerLen, streamSize ); } +#ifdef DEBUG + newMsgElem->checksum = g_compute_checksum_for_data( G_CHECKSUM_MD5, + newMsgElem->msg, + newMsgElem->len ); +#endif return newMsgElem; } /* makeElemWithID */ @@ -951,8 +962,8 @@ printQueue( const CommsCtxt* comms ) for ( elem = comms->msgQueueHead, i = 0; i < comms->queueLen; elem = elem->next, ++i ) { - XP_STATUSF( "\t%d: channel: %x; msgID=" XP_LD, - i+1, elem->channelNo, elem->msgID ); + XP_STATUSF( "\t%d: channel: %x; msgID=" XP_LD "; check=%s", + i+1, elem->channelNo, elem->msgID, elem->checksum ); } } @@ -970,6 +981,7 @@ assertQueueOk( const CommsCtxt* comms ) } } XP_ASSERT( count == comms->queueLen ); + XP_ASSERT( count < 10 ); } #endif @@ -977,6 +989,9 @@ static void freeElem( const CommsCtxt* XP_UNUSED_DBG(comms), MsgQueueElem* elem ) { XP_FREE( comms->mpool, elem->msg ); +#ifdef DEBUG + g_free( elem->checksum ); +#endif XP_FREE( comms->mpool, elem ); } @@ -1011,7 +1026,7 @@ removeFromQueue( CommsCtxt* comms, XP_PlayerAddr channelNo, MsgID msgID ) queue, and receiving something from the server is an implicit ACK -- IFF it isn't left over from the last game. */ - if ( (elem->channelNo == 0) && (channelNo != 0) ) { + if ( ((CHANNEL_MASK & elem->channelNo) == 0) && (channelNo!= 0) ) { XP_ASSERT( !comms->isServer ); XP_ASSERT( elem->msgID == 0 ); } else if ( elem->channelNo != channelNo ) { From 211e9ded7fdd63fb21ae7f090422bbffce62bc5a Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 18 Oct 2010 20:18:24 -0700 Subject: [PATCH 2/3] TIMEOUT needs to be bigger for small NGAMES values --- xwords4/linux/scripts/discon_ok2.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwords4/linux/scripts/discon_ok2.sh b/xwords4/linux/scripts/discon_ok2.sh index f08e7446b..5d3f1db53 100755 --- a/xwords4/linux/scripts/discon_ok2.sh +++ b/xwords4/linux/scripts/discon_ok2.sh @@ -4,7 +4,7 @@ NGAMES=${NGAMES:-1} NROOMS=${NROOMS:-1} HOST=${HOST:-localhost} PORT=${PORT:-10997} -TIMEOUT=${TIMEOUT:-$((NGAMES*60))} +TIMEOUT=${TIMEOUT:-$((NGAMES*60+500))} DICTS=${DICTS:-dict.xwd} SAVE_GOOD=${SAVE_GOOD:-YES} From 9ba2d2f1776e07924a5de7870d70f133deaf7c3b Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 18 Oct 2010 20:19:09 -0700 Subject: [PATCH 3/3] default msgs entry timestamps to 'now' --- xwords4/relay/xwrelay.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwords4/relay/xwrelay.sh b/xwords4/relay/xwrelay.sh index 856a8a9ef..7aaf6712c 100755 --- a/xwords4/relay/xwrelay.sh +++ b/xwords4/relay/xwrelay.sh @@ -51,7 +51,7 @@ CREATE TABLE msgs ( id SERIAL ,connName VARCHAR(64) ,hid INTEGER -,ctime TIMESTAMP +,ctime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,msg BYTEA ); EOF