truncate also on error from fflush and fsync
authorMichal Voců <michal@ruk.cuni.cz>
Wed, 16 Mar 2011 16:17:08 +0000 (16:17 +0000)
committerMichal Voců <michal@ruk.cuni.cz>
Wed, 16 Mar 2011 16:17:08 +0000 (16:17 +0000)
org.glite.lb.common/src/log_msg.c
org.glite.lb.common/src/perftest_common.sh

index 94b7191..d625517 100644 (file)
@@ -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;
        }
 
index 7d93378..656e8b2 100644 (file)
@@ -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