From 0cf94dda8b084d9b5612537bef61a602182d7a0d Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 12 Oct 2010 19:16:46 -0700 Subject: [PATCH 1/6] fix frequent assertion failure that dates from when no messages passed outside of ALLCOND state. With this fix the test script is running all games to completion if given enough time. --- xwords4/common/comms.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index acd55b5bf..5d317925b 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -1254,15 +1254,18 @@ relayPreProcess( CommsCtxt* comms, XWStreamCtxt* stream, XWHostID* senderID ) cookieID, srcID, destID ); /* If these values don't check out, drop it */ - consumed = destID != comms->r.myHostID; - /* it's ok for cookieID not to match */ - if ( !consumed ) { - if ( COMMS_RELAYSTATE_ALLCONNECTED == comms->r.relayState ) { - consumed = cookieID != comms->r.cookieID; - } else { - XP_ASSERT( COMMS_RELAYSTATE_RECONNECTED == comms->r.relayState ); /* this is firing */ - } + XP_ASSERT( COMMS_RELAYSTATE_ALLCONNECTED == comms->r.relayState + || COMMS_RELAYSTATE_CONNECTED == comms->r.relayState + || COMMS_RELAYSTATE_RECONNECTED == comms->r.relayState ); + + if ( destID == comms->r.myHostID ) { /* When would this not happen? */ + consumed = XP_FALSE; + } else if ( cookieID == comms->r.cookieID ) { + XP_LOGF( "%s: keeping message though hostID not what expected (%d vs %d)", + __func__, destID, comms->r.myHostID ); + consumed = XP_FALSE; } + if ( consumed ) { XP_LOGF( "%s: rejecting data message", __func__ ); } else { From 40a7a1b5a39d7c72d6b50b7e2ce57927733e55b6 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 12 Oct 2010 19:17:42 -0700 Subject: [PATCH 2/6] cleanup; track checked rooms rather than checking each time seen --- xwords4/linux/scripts/discon_ok2.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/xwords4/linux/scripts/discon_ok2.sh b/xwords4/linux/scripts/discon_ok2.sh index 34299e9ad..206bf206d 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:-1000} +TIMEOUT=${TIMEOUT:-$((NGAMES*60))} DICT=${DICT:-dict.xwd} NAMES=(UNUSED Brynn Ariela Kati Eric) @@ -50,14 +50,19 @@ while [ -n "$1" ]; do shift done +declare -A CHECKED_ROOMS check_room() { ROOM=$1 - NUM=$(echo "SELECT COUNT(*) FROM games WHERE ntotal!=sum_array(nperdevice) AND room='$ROOM'" | - psql -q -t xwgames) - NUM=$((NUM+0)) - if [ "$NUM" -gt 0 ]; then - echo "There are unconsummated games in $ROOM in the DB. This test will fail if you don't remove them." - exit 0 + if [ -z "${CHECKED_ROOMS[$ROOM]}" ]; then + NUM=$(echo "SELECT COUNT(*) FROM games WHERE ntotal!=sum_array(nperdevice) AND room='$ROOM'" | + psql -q -t xwgames) + NUM=$((NUM+0)) + if [ "$NUM" -gt 0 ]; then + echo "$ROOM in the DB has unconsummated games. Remove them." + exit 0 + else + CHECKED_ROOMS[$ROOM]=1 + fi fi } @@ -176,10 +181,11 @@ print_stats() { : } +echo "*********$0 starting: $(date)**************" + build_cmds run_cmds print_stats wait -echo -n "$0 done: " -date +echo "*********$0 finished: $(date)**************" From c92d59fa53a6ac7c8cbfcb4226446b6aa91b0960 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 14 Oct 2010 05:59:45 -0700 Subject: [PATCH 3/6] games can be started with multiple dicts; saving of successful games/logs optional --- xwords4/linux/scripts/discon_ok2.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/xwords4/linux/scripts/discon_ok2.sh b/xwords4/linux/scripts/discon_ok2.sh index 206bf206d..c75c5b062 100755 --- a/xwords4/linux/scripts/discon_ok2.sh +++ b/xwords4/linux/scripts/discon_ok2.sh @@ -5,7 +5,13 @@ NROOMS=${NROOMS:-1} HOST=${HOST:-localhost} PORT=${PORT:-10997} TIMEOUT=${TIMEOUT:-$((NGAMES*60))} -DICT=${DICT:-dict.xwd} +DICTS=${DICTS:-dict.xwd} +SAVE_GOOD=${SAVE_GOOD:-YES} + +declare -a DICTS_ARR +for DICT in $DICTS; do + DICTS_ARR[${#DICTS_ARR[*]}]=$DICT +done NAMES=(UNUSED Brynn Ariela Kati Eric) @@ -29,7 +35,7 @@ fi usage() { echo "usage: [env=val *] $0" 1>&2 echo " current env variables and their values: " 1>&2 - for VAR in NGAMES NROOMS USE_GTK TIMEOUT HOST PORT DICT; do + for VAR in NGAMES NROOMS USE_GTK TIMEOUT HOST PORT DICTS SAVE_GOOD; do echo "$VAR:" $(eval "echo \$${VAR}") 1>&2 done exit 0 @@ -72,6 +78,7 @@ build_cmds() { ROOM=ROOM_$((GAME % NROOMS)) check_room $ROOM NDEVS=$(($RANDOM%3+2)) + DICT=${DICTS_ARR[$((GAME%${#DICTS_ARR[*]}))]} unset OTHERS for II in $(seq 2 $NDEVS); do @@ -108,9 +115,14 @@ close_device() { fi unset PIDS[$ID] unset CMDS[$ID] - [ -f ${FILES[$ID]} ] && mv ${FILES[$ID]} $MVTO + if [ "$SAVE_GOOD" = YES ]; then + [ -f ${FILES[$ID]} ] && mv ${FILES[$ID]} $MVTO + mv ${LOGS[$ID]} $MVTO + else + rm -f ${FILES[$ID]} + rm -f ${LOGS[$ID]} + fi unset FILES[$ID] - mv ${LOGS[$ID]} $MVTO unset LOGS[$ID] } From e5c7f476ba7f418b89ce2aca31edac4563c38aac Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 14 Oct 2010 22:15:41 -0700 Subject: [PATCH 4/6] get rid of microseconds in timestamps --- xwords4/relay/xwrelay.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xwords4/relay/xwrelay.sh b/xwords4/relay/xwrelay.sh index 66ef24657..856a8a9ef 100755 --- a/xwords4/relay/xwrelay.sh +++ b/xwords4/relay/xwrelay.sh @@ -41,8 +41,8 @@ cid integer ,nPerDevice INTEGER[] ,seeds INTEGER[] ,nSent INTEGER DEFAULT 0 -,ctime TIMESTAMP DEFAULT CURRENT_TIMESTAMP -,mtime TIMESTAMP +,ctime TIMESTAMP (0) DEFAULT CURRENT_TIMESTAMP +,mtime TIMESTAMP (0) ); EOF From 34df1490469861ca9729281df192697bb85831c5 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 14 Oct 2010 22:16:21 -0700 Subject: [PATCH 5/6] include age of room with info returned for open public rooms --- xwords4/relay/dbmgr.cpp | 7 +++++-- xwords4/relay/dbmgr.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xwords4/relay/dbmgr.cpp b/xwords4/relay/dbmgr.cpp index 6355dc125..c7f578197 100644 --- a/xwords4/relay/dbmgr.cpp +++ b/xwords4/relay/dbmgr.cpp @@ -233,8 +233,9 @@ DBMgr::ClearCIDs( void ) void DBMgr::PublicRooms( int lang, int nPlayers, int* nNames, string& names ) { - const char* fmt = "SELECT room, nTotal-sum_array(nPerDevice)" - " FROM " GAMES_TABLE + const char* fmt = "SELECT room, nTotal-sum_array(nPerDevice)," + " round( extract( epoch from age('now', ctime)))" + " FROM " GAMES_TABLE " WHERE pub = TRUE" " AND lang = %d" " AND nTotal>sum_array(nPerDevice)" @@ -250,6 +251,8 @@ DBMgr::PublicRooms( int lang, int nPlayers, int* nNames, string& names ) names.append( PQgetvalue( result, ii, 0 ) ); names.append( "/" ); names.append( PQgetvalue( result, ii, 1 ) ); + names.append( "/" ); + names.append( PQgetvalue( result, ii, 2 ) ); names.append( "\n" ); } PQclear( result ); diff --git a/xwords4/relay/dbmgr.h b/xwords4/relay/dbmgr.h index e7bafc970..e32f5941a 100644 --- a/xwords4/relay/dbmgr.h +++ b/xwords4/relay/dbmgr.h @@ -53,7 +53,7 @@ class DBMgr { void ClearCID( const char* connName ); void RecordSent( const char* const connName, int nBytes ); - /* Return list of roomName/playersStillWanted for open public games + /* Return list of roomName/playersStillWanted/age for open public games matching this language and total game size. Will probably want to cache lists locally and only update them every few seconds to avoid to many queries.*/ From 38ae2faacc0609bec413ac23a39e8779e1034411 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 14 Oct 2010 22:17:34 -0700 Subject: [PATCH 6/6] don't nuke bad files along with good --- xwords4/linux/scripts/discon_ok2.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xwords4/linux/scripts/discon_ok2.sh b/xwords4/linux/scripts/discon_ok2.sh index c75c5b062..f08e7446b 100755 --- a/xwords4/linux/scripts/discon_ok2.sh +++ b/xwords4/linux/scripts/discon_ok2.sh @@ -18,8 +18,11 @@ NAMES=(UNUSED Brynn Ariela Kati Eric) LOGDIR=$(basename $0)_logs [ -d $LOGDIR ] && mv $LOGDIR /tmp/${LOGDIR}_$$ mkdir -p $LOGDIR -DONEDIR=$LOGDIR/done -mkdir -p $DONEDIR + +if [ "$SAVE_GOOD" = YES ]; then + DONEDIR=$LOGDIR/done + mkdir -p $DONEDIR +fi USE_GTK=${USE_GTK:-FALSE} @@ -115,7 +118,7 @@ close_device() { fi unset PIDS[$ID] unset CMDS[$ID] - if [ "$SAVE_GOOD" = YES ]; then + if [ -n "$MVTO" ]; then [ -f ${FILES[$ID]} ] && mv ${FILES[$ID]} $MVTO mv ${LOGS[$ID]} $MVTO else