[BB#109] Fix crash (infinite loop) when writing to log file fails.
[obnox/tinyproxy.git] / src / log.c
index ba871b215f8ea0ac14a4d53b1bad8227ab67a150..f5a0b44cf8fab3aa62bcdb66c56902a1115178e4 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -188,8 +188,13 @@ void log_message (int level, const char *fmt, ...)
 
                 ret = write (log_file_fd, str, strlen (str));
                 if (ret == -1) {
-                        log_message (LOG_WARNING,
-                                     "Could not write to log file");
+                        config.syslog = TRUE;
+
+                        log_message(LOG_CRIT, "ERROR: Could not write to log "
+                                    "file %s: %s.",
+                                    config.logf_name, strerror(errno));
+                        log_message(LOG_CRIT,
+                                    "Falling back to syslog logging");
                 }
 
                 fsync (log_file_fd);