summaryrefslogtreecommitdiffstats
path: root/src/global/maillog_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/global/maillog_client.c')
-rw-r--r--src/global/maillog_client.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/global/maillog_client.c b/src/global/maillog_client.c
index 34952ef..a6e8436 100644
--- a/src/global/maillog_client.c
+++ b/src/global/maillog_client.c
@@ -120,6 +120,7 @@ static int maillog_client_flags;
static void maillog_client_logwriter_fallback(const char *text)
{
static int fallback_guard = 0;
+ static VSTREAM *fp;
/*
* Guard against recursive calls.
@@ -129,10 +130,20 @@ static void maillog_client_logwriter_fallback(const char *text)
* logfile. All we can do is to hope that stderr logging will bring out
* the bad news.
*/
- if (fallback_guard == 0 && var_maillog_file && *var_maillog_file
- && logwriter_one_shot(var_maillog_file, text, strlen(text)) < 0) {
- fallback_guard = 1;
- msg_fatal("logfile '%s' write error: %m", var_maillog_file);
+ if (fallback_guard++ == 0 && var_maillog_file && *var_maillog_file) {
+ if (text == 0 && fp != 0) {
+ (void) vstream_fclose(fp);
+ fp = 0;
+ }
+ if (fp == 0) {
+ fp = logwriter_open_or_die(var_maillog_file);
+ close_on_exec(vstream_fileno(fp), CLOSE_ON_EXEC);
+ }
+ if (text && (logwriter_write(fp, text, strlen(text)) != 0 ||
+ vstream_fflush(fp) != 0)) {
+ msg_fatal("logfile '%s' write error: %m", var_maillog_file);
+ }
+ fallback_guard = 0;
}
}