mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-15 15:41:24 +01:00
simulate games being deleted before they're finished
This commit is contained in:
parent
7a2d279308
commit
a1caaeb183
1 changed files with 34 additions and 5 deletions
|
@ -8,6 +8,7 @@ PORT=${PORT:-10997}
|
||||||
TIMEOUT=${TIMEOUT:-$((NGAMES*60+500))}
|
TIMEOUT=${TIMEOUT:-$((NGAMES*60+500))}
|
||||||
DICTS=${DICTS:-dict.xwd}
|
DICTS=${DICTS:-dict.xwd}
|
||||||
SAVE_GOOD=${SAVE_GOOD:-YES}
|
SAVE_GOOD=${SAVE_GOOD:-YES}
|
||||||
|
RESIGN_RATIO=${RESIGN_RATIO:-$((NGAMES/3))}
|
||||||
|
|
||||||
declare -a DICTS_ARR
|
declare -a DICTS_ARR
|
||||||
for DICT in $DICTS; do
|
for DICT in $DICTS; do
|
||||||
|
@ -24,6 +25,8 @@ if [ "$SAVE_GOOD" = YES ]; then
|
||||||
DONEDIR=$LOGDIR/done
|
DONEDIR=$LOGDIR/done
|
||||||
mkdir -p $DONEDIR
|
mkdir -p $DONEDIR
|
||||||
fi
|
fi
|
||||||
|
DEADDIR=$LOGDIR/dead
|
||||||
|
mkdir -p $DEADDIR
|
||||||
|
|
||||||
USE_GTK=${USE_GTK:-FALSE}
|
USE_GTK=${USE_GTK:-FALSE}
|
||||||
|
|
||||||
|
@ -109,7 +112,8 @@ build_cmds() {
|
||||||
COUNTER=$((COUNTER+1))
|
COUNTER=$((COUNTER+1))
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
}
|
echo "finished creating $COUNTER commands"
|
||||||
|
} # build_cmds
|
||||||
|
|
||||||
launch() {
|
launch() {
|
||||||
LOG=${LOGS[$1]}
|
LOG=${LOGS[$1]}
|
||||||
|
@ -137,6 +141,28 @@ close_device() {
|
||||||
unset LOGS[$ID]
|
unset LOGS[$ID]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kill_from_log() {
|
||||||
|
LOG=$1
|
||||||
|
RELAYID=$(./scripts/relayID.sh $LOG)
|
||||||
|
if [ -n "$RELAYID" ]; then
|
||||||
|
../relay/rq -d $RELAYID 2>/dev/null || true
|
||||||
|
return 0 # success
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
maybe_resign() {
|
||||||
|
KEY=$1
|
||||||
|
LOG=${LOGS[$KEY]}
|
||||||
|
if grep -q XWRELAY_ALLHERE $LOG; then
|
||||||
|
if [ 0 -eq $(($RANDOM % $RESIGN_RATIO)) ]; then
|
||||||
|
echo "making $LOG $(connName $LOG) resign..."
|
||||||
|
kill_from_log $LOG && close_device $KEY $DEADDIR
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
check_game() {
|
check_game() {
|
||||||
KEY=$1
|
KEY=$1
|
||||||
LOG=${LOGS[$KEY]}
|
LOG=${LOGS[$KEY]}
|
||||||
|
@ -164,13 +190,16 @@ check_game() {
|
||||||
echo -n "Closing $CONNNAME: "
|
echo -n "Closing $CONNNAME: "
|
||||||
for ID in $OTHERS $KEY; do
|
for ID in $OTHERS $KEY; do
|
||||||
echo -n "${LOGS[$ID]}, "
|
echo -n "${LOGS[$ID]}, "
|
||||||
RELAYID=$(./scripts/relayID.sh ${LOGS[$ID]})
|
kill_from_log ${LOGS[$ID]} || true
|
||||||
if [ -n "$RELAYID" ]; then
|
|
||||||
../relay/rq -d $RELAYID 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
close_device $ID $DONEDIR
|
close_device $ID $DONEDIR
|
||||||
done
|
done
|
||||||
date
|
date
|
||||||
|
elif grep -q 'relay_error_curses(XWRELAY_ERROR_DELETED)' $LOG; then
|
||||||
|
echo "deleting $LOG $(connName $LOG) b/c another resigned"
|
||||||
|
kill_from_log $LOG || true
|
||||||
|
close_device $KEY $DEADDIR
|
||||||
|
else
|
||||||
|
maybe_resign $KEY
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue