From e5e5e339ccd7a2cb100b87953b181e317fd3c5db Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Voc=C5=AF?= Date: Wed, 16 Mar 2011 16:17:08 +0000 Subject: [PATCH] truncate also on error from fflush and fsync --- org.glite.lb.common/src/log_msg.c | 4 ++++ org.glite.lb.common/src/perftest_common.sh | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/org.glite.lb.common/src/log_msg.c b/org.glite.lb.common/src/log_msg.c index 94b7191..d625517 100644 --- a/org.glite.lb.common/src/log_msg.c +++ b/org.glite.lb.common/src/log_msg.c @@ -210,10 +210,14 @@ try_again: } if ( fflush(outfile) == EOF ) { edg_wll_SetError(ctx, errno, "fflush()"); + /* partially written message may corrupt event file */ + ftruncate(filedesc, *filepos); goto cleanup; } if ( fsync(filedesc) < 0 ) { edg_wll_SetError(ctx, errno, "fsync()"); + /* partially written message may corrupt event file */ + ftruncate(filedesc, *filepos); goto cleanup; } diff --git a/org.glite.lb.common/src/perftest_common.sh b/org.glite.lb.common/src/perftest_common.sh index 7d93378..656e8b2 100644 --- a/org.glite.lb.common/src/perftest_common.sh +++ b/org.glite.lb.common/src/perftest_common.sh @@ -74,9 +74,9 @@ check_test_files() get_result() { tmpfile=`mktemp -p /tmp` - grep PERFTEST $CONSUMER_LOG > $tmpfile + grep -a PERFTEST $CONSUMER_LOG > $tmpfile . $tmpfile - grep PERFTEST $PRODUCER_LOG > $tmpfile + grep -a PERFTEST $PRODUCER_LOG > $tmpfile . $tmpfile rm $tmpfile [[ $DEBUG -gt 0 ]] && echo "Timestamps: from $PERFTEST_BEGIN_TIMESTAMP to $PERFTEST_END_TIMESTAMP" @@ -177,13 +177,13 @@ run_test() [[ $DEBUG -gt 0 ]] && echo -e "\n\nRunning test with input $file" savePERFTEST_NAME=$PERFTEST_NAME PERFTEST_NAME="${PERFTEST_NAME}_${JOB_DESC[i]}" - linesbefore=`grep PERFTEST $CONSUMER_LOG|wc -l` + linesbefore=`grep -a PERFTEST $CONSUMER_LOG|wc -l` $LOGJOBS $lj_flags -f $file >> $PRODUCER_LOG 2>&1 - linesafter=`grep PERFTEST $CONSUMER_LOG|wc -l` + linesafter=`grep -a PERFTEST $CONSUMER_LOG|wc -l` PERFTEST_NAME=$savePERFTEST_NAME # if there are no new lines in the log, give it some time [[ $linesbefore -eq $linesafter ]] && sleep 5 - linesafter=`grep PERFTEST $CONSUMER_LOG|wc -l` + linesafter=`grep -a PERFTEST $CONSUMER_LOG|wc -l` [[ $DEBUG -gt 0 ]] && echo "Lines before " $linesbefore ", after " $linesafter if [[ $linesbefore -eq $linesafter ]] then -- 1.8.2.3