From 088a1d37e991673afcb7584c26e0921932a6d066 Mon Sep 17 00:00:00 2001 From: Jacob Nevins Date: Thu, 12 Aug 2004 01:02:01 +0000 Subject: [PATCH] Flush the logfile reasonably frequently in `printable output only' and `all session data' modes, without completely mauling the performance, by fflush()ing once per term_out(). If anyone complains I suppose we can make this optional. [originally from svn r4445] --- logging.c | 10 ++++++++++ putty.h | 1 + terminal.c | 1 + 3 files changed, 12 insertions(+) diff --git a/logging.c b/logging.c index f32e9cae..5302998f 100644 --- a/logging.c +++ b/logging.c @@ -34,6 +34,16 @@ void logtraffic(void *handle, unsigned char c, int logmode) } } +/* + * Flush any open log file. + */ +void logflush(void *handle) { + struct LogContext *ctx = (struct LogContext *)handle; + if (ctx->cfg.logtype > 0) + if (ctx->lgfp) + fflush(ctx->lgfp); +} + /* * Log an Event Log entry. Used in SSH packet logging mode; this is * also as convenient a place as any to put the output of Event Log diff --git a/putty.h b/putty.h index 6d4d83ae..3fb26bcc 100644 --- a/putty.h +++ b/putty.h @@ -655,6 +655,7 @@ void log_reconfig(void *logctx, Config *cfg); void logfopen(void *logctx); void logfclose(void *logctx); void logtraffic(void *logctx, unsigned char c, int logmode); +void logflush(void *logctx); void log_eventlog(void *logctx, const char *string); enum { PKT_INCOMING, PKT_OUTGOING }; void log_packet(void *logctx, int direction, int type, diff --git a/terminal.c b/terminal.c index bf531eee..00fd7c85 100644 --- a/terminal.c +++ b/terminal.c @@ -3311,6 +3311,7 @@ void term_out(Terminal *term) } term_print_flush(term); + logflush(term->logctx); } #if 0