Re: cvs: php-src(PHP_5_2) /main main.c
| From: | Marcus Boerger | Date: | Fri, 06 Apr 2007 15:17:46 +0000 |
| Subject: | Re: cvs: php-src(PHP_5_2) /main main.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-43748@lists.php.net to get a copy of this message | ||
Hello Ilia,
care to MFB your latest changes?
best regards
marcus
Friday, April 6, 2007, 3:58:48 PM, you wrote:
> iliaa Fri Apr 6 13:58:48 2007 UTC
> Modified files: (Branch: PHP_5_2)
> /php-src/main main.c
> Log:
> Avoid locks when appening to the error log file
>
>
>
> http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.640.2.23.2.32&r2=1.640.2.23.2.33&diff_format=u
> Index: php-src/main/main.c
> diff -u php-src/main/main.c:1.640.2.23.2.32 php-src/main/main.c:1.640.2.23.2.33
> --- php-src/main/main.c:1.640.2.23.2.32 Sun Apr 1 19:29:42 2007
> +++ php-src/main/main.c Fri Apr 6 13:58:48 2007
> @@ -18,7 +18,7 @@
> +----------------------------------------------------------------------+
> */
>
> -/* $Id: main.c,v 1.640.2.23.2.32 2007/04/01 19:29:42 iliaa Exp $ */
> +/* $Id: main.c,v 1.640.2.23.2.33 2007/04/06 13:58:48 iliaa Exp $ */
>
> /* {{{ includes
> */
> @@ -27,6 +27,7 @@
>
> #include "php.h"
> #include <stdio.h>
> +#include <fcntl.h>
> #ifdef PHP_WIN32
> #include "win32/time.h"
> #include "win32/signal.h"
> @@ -59,10 +60,8 @@
> #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>
> #include "win32/php_registry.h"
> #endif
> #include "php_syslog.h"
> @@ -343,7 +342,7 @@
> */
> PHPAPI void php_log_err(char *log_message TSRMLS_DC)
> {
> - FILE *log_file;
> + int fd = -1;
> char error_time_str[128];
> struct tm tmbuf;
> time_t error_time;
> @@ -356,13 +355,16 @@
> return;
> }
> #endif
> - log_file = VCWD_FOPEN(PG(error_log), "ab");
> - if (log_file != NULL) {
> + fd = VCWD_OPEN_MODE(PG(error_log), O_CREAT | O_APPEND | O_WRONLY, 0644);
> + if (fd != -1) {
> + char *tmp;
> + int len;
> time(&error_time);
> 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);
> + len = spprintf(&tmp, 0, "[%s] %s%s",
> error_time_str, log_message, PHP_EOL);
> + write(fd, tmp, len);
> + efree(tmp);
> + close(fd);
> return;
> }
> }
Best regards,
Marcus