From 58f31eb229a0146f31dd82356a4f1936c2220c84 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 9 Dec 2012 12:28:14 +0000 Subject: [PATCH] Let fatal_error() write to the logfile right away .. before showing the Windows-specific error message which blocks until the user acknowledges it, thus complicating automatic error detection. Reported by Adriaan in #3593603. --- errlog.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/errlog.c b/errlog.c index ddcc39b2..5026a1e0 100644 --- a/errlog.c +++ b/errlog.c @@ -1,4 +1,4 @@ -const char errlog_rcs[] = "$Id: errlog.c,v 1.115 2012/07/27 17:27:47 fabiankeil Exp $"; +const char errlog_rcs[] = "$Id: errlog.c,v 1.116 2012/07/27 17:39:57 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/errlog.c,v $ @@ -146,25 +146,27 @@ static inline void unlock_loginit() {} *********************************************************************/ static void fatal_error(const char *error_message) { -#if defined(_WIN32) && !defined(_WIN_CONSOLE) - /* Skip timestamp and thread id for the message box. */ - const char *box_message = strstr(error_message, "Fatal error"); - if (NULL == box_message) + if (logfp != NULL) { - /* Shouldn't happen but ... */ - box_message = error_message; + fputs(error_message, logfp); } - MessageBox(g_hwndLogFrame, box_message, "Privoxy Error", - MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST); - /* Cleanup - remove taskbar icon etc. */ - TermLogWindow(); -#endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */ - - if (logfp != NULL) +#if defined(_WIN32) && !defined(_WIN_CONSOLE) { - fputs(error_message, logfp); + /* Skip timestamp and thread id for the message box. */ + const char *box_message = strstr(error_message, "Fatal error"); + if (NULL == box_message) + { + /* Shouldn't happen but ... */ + box_message = error_message; + } + MessageBox(g_hwndLogFrame, box_message, "Privoxy Error", + MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST); + + /* Cleanup - remove taskbar icon etc. */ + TermLogWindow(); } +#endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */ #if defined(unix) if (pidfile) -- 2.39.2