From 2a79312e325ce09acf1af83bf205a47279045993 Mon Sep 17 00:00:00 2001 From: martin-s Date: Wed, 16 Jan 2008 18:21:52 +0000 Subject: [PATCH] Fix:Core:Write a proper end to the logfiles even if navit crashes git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@779 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/src/log.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/navit/src/log.c b/navit/src/log.c index 1c4a49a..2bc0cd9 100644 --- a/navit/src/log.c +++ b/navit/src/log.c @@ -78,7 +78,7 @@ static void log_close(struct log *this_) { if (this_->trailer.len) - fwrite(this_->header.data, 1, this_->trailer.len, this_->f); + fwrite(this_->trailer.data, 1, this_->trailer.len, this_->f); fflush(this_->f); fclose(this_->f); this_->f=NULL; @@ -87,6 +87,7 @@ log_close(struct log *this_) static void log_flush(struct log *this_) { + long pos; if (this_->empty) { if (this_->header.len) fwrite(this_->header.data, 1, this_->header.len, this_->f); @@ -94,6 +95,14 @@ log_flush(struct log *this_) this_->empty=0; } fwrite(this_->data.data, 1, this_->data.len, this_->f); + if (this_->trailer.len) { + pos=ftell(this_->f); + if (pos > 0) { + fwrite(this_->trailer.data, 1, this_->trailer.len, this_->f); + fseek(this_->f, pos, SEEK_SET); + } + } + fflush(this_->f); g_free(this_->data.data); this_->data.data=NULL; -- 2.7.4