From 878364957e5c8f8ac236de69a6c9ff5a89a424f6 Mon Sep 17 00:00:00 2001 From: martin-s Date: Tue, 23 Sep 2008 20:59:58 +0000 Subject: [PATCH] Fix:core:Fixed various logging bugs git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1406 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/log.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/navit/navit/log.c b/navit/navit/log.c index f571b79..137bb95 100644 --- a/navit/navit/log.c +++ b/navit/navit/log.c @@ -85,6 +85,12 @@ expand_filenames(struct log *this_) } static void +log_set_last_flush(struct log *this_) +{ + gettimeofday(&this_->last_flush, NULL); +} + +static void log_open(struct log *this_) { char *mode; @@ -102,7 +108,7 @@ log_open(struct log *this_) if (!this_->overwrite) fseek(this_->f, 0, SEEK_END); this_->empty = !ftell(this_->f); - gettimeofday(&this_->last_flush, NULL); + log_set_last_flush(this_); } static void @@ -147,7 +153,7 @@ log_flush(struct log *this_) g_free(this_->data.data); this_->data.data=NULL; this_->data.max_len=this_->data.len=0; - gettimeofday(&this_->last_flush, NULL); + log_set_last_flush(this_); } static int @@ -185,7 +191,7 @@ log_timer(gpointer data) gettimeofday(&tv, NULL); delta=(tv.tv_sec-this_->last_flush.tv_sec)*1000+(tv.tv_usec-this_->last_flush.tv_usec)/1000; dbg(1,"delta=%d flush_time=%d\n", delta, this_->flush_time); - if (this_->flush_time && delta > this_->flush_time*1000) + if (this_->flush_time && delta >= this_->flush_time*1000) log_flush(this_); return TRUE; } @@ -239,7 +245,9 @@ log_new(struct attr **attrs) ret->timer=g_timeout_add(ret->flush_time*1000, log_timer, ret); } expand_filenames(ret); - if (! ret->lazy) + if (ret->lazy) + log_set_last_flush(ret); + else log_open(ret); ret->attrs=attr_list_dup(attrs); return ret; -- 2.7.4