]> granicus.if.org Git - php/commitdiff
Fixed bug #40897 (error_log file not locked)
authorIlia Alshanetsky <iliaa@php.net>
Sun, 1 Apr 2007 19:29:42 +0000 (19:29 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 1 Apr 2007 19:29:42 +0000 (19:29 +0000)
NEWS
main/main.c

diff --git a/NEWS b/NEWS
index 72c36cba026cdb0489cd9331f954909ed0d63f8c..785f8a656d467bb3cf7c73fd320bdc2e2369467c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,7 @@ PHP                                                                        NEWS
   exceeded). (trickie at gmail dot com, Ilia)
 - Fixed bug #40915 (addcslashes unexpected behavior with binary input). (Tony)
 - Fixed bug #40899 (memory leak when nesting list()). (Dmitry)
+- Fixed bug #40897 (error_log file not locked). (Ilia)
 - Fixed bug #40883 (mysql_query() is allocating memory incorrectly). (Tony)
 - Fixed bug #40872 (inconsistency in offsetSet, offsetExists treatment of 
   string enclosed integers). (Marcus)
index 822c30e0cd76cca6592f0998c10726f2a810f67f..e556e70bc4c53223cef9f2c989e09538e652e688 100644 (file)
@@ -59,6 +59,7 @@
 #include "ext/standard/php_standard.h"
 #include "php_variables.h"
 #include "ext/standard/credits.h"
+#include "ext/standard/flock_compat.h"
 #ifdef PHP_WIN32
 #include <io.h>
 #include <fcntl.h>
@@ -358,10 +359,9 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC)
                log_file = VCWD_FOPEN(PG(error_log), "ab");
                if (log_file != NULL) {
                        time(&error_time);
-                       strftime(error_time_str, sizeof(error_time_str), "%d-%b-%Y %H:%M:%S", php_localtime_r(&error_time, &tmbuf)); 
-                       fprintf(log_file, "[%s] ", error_time_str);
-                       fprintf(log_file, "%s", log_message);
-                       fprintf(log_file, "%s", PHP_EOL);
+                       strftime(error_time_str, sizeof(error_time_str), "%d-%b-%Y %H:%M:%S", php_localtime_r(&error_time, &tmbuf));
+                       php_flock(fileno(log_file), 2);
+                       fprintf(log_file, "[%s] %s%s", error_time_str, log_message, PHP_EOL);
                        fclose(log_file);
                        return;
                }