From c4bf153d36843a10a14669ecef7e58f938fdf073 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 20 Jan 2011 18:10:33 -0800 Subject: [PATCH] log reason game ended to game's logfile --- xwords4/linux/scripts/discon_ok2.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xwords4/linux/scripts/discon_ok2.sh b/xwords4/linux/scripts/discon_ok2.sh index 55b213fc7..09f85ae69 100755 --- a/xwords4/linux/scripts/discon_ok2.sh +++ b/xwords4/linux/scripts/discon_ok2.sh @@ -128,12 +128,14 @@ launch() { close_device() { ID=$1 MVTO=$2 + REASON="$3" if [ ${PIDS[$ID]} -ne 0 ]; then kill ${PIDS[$ID]} 2>/dev/null wait ${PIDS[$ID]} fi unset PIDS[$ID] unset CMDS[$ID] + echo "closing game: $REASON" >> ${LOGS[$ID]} if [ -n "$MVTO" ]; then [ -f ${FILES[$ID]} ] && mv ${FILES[$ID]} $MVTO mv ${LOGS[$ID]} $MVTO @@ -178,7 +180,7 @@ maybe_resign() { 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 + kill_from_log $LOG && close_device $KEY $DEADDIR "resignation forced" fi fi fi @@ -213,13 +215,13 @@ check_game() { for ID in $OTHERS $KEY; do echo -n "${LOGS[$ID]}, " kill_from_log ${LOGS[$ID]} || true - close_device $ID $DONEDIR + close_device $ID $DONEDIR "game over" done 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 + close_device $KEY $DEADDIR "other resigned" else maybe_resign $KEY fi @@ -250,7 +252,7 @@ run_cmds() { mkdir -p ${LOGDIR}/not_done echo "processing unfinished games...." for KEY in ${!CMDS[*]}; do - close_device $KEY ${LOGDIR}/not_done + close_device $KEY ${LOGDIR}/not_done "unfinished game" done fi }