From 11cc5e30c81503e5769e32e75d0455b193111eec Mon Sep 17 00:00:00 2001 From: jacob 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. git-svn-id: svn://svn.tartarus.org/sgt/putty@4445 cda61777-01e9-0310-a592-d414129be87e --- 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 @@ -35,6 +35,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 * entries to stderr when a command-line tool is in verbose mode. 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 -- 2.11.0