From 6901e094921d95ba2cb71a9fa002c767eee8468b Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Mon, 20 Mar 2006 23:07:31 +0000 Subject: [PATCH] MF51: fix #36808 (syslog ident becomes garbage between requests) --- ext/standard/basic_functions.c | 3 +++ ext/standard/php_ext_syslog.h | 1 + ext/standard/syslog.c | 19 ++++++++++++------- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 9c28d6c158..6791c946f6 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1113,6 +1113,9 @@ PHP_MSHUTDOWN_FUNCTION(basic) PHP_MSHUTDOWN(url_scanner_ex)(SHUTDOWN_FUNC_ARGS_PASSTHRU); PHP_MSHUTDOWN(file)(SHUTDOWN_FUNC_ARGS_PASSTHRU); PHP_MSHUTDOWN(standard_filters)(SHUTDOWN_FUNC_ARGS_PASSTHRU); +#ifdef HAVE_SYSLOG_H + PHP_MSHUTDOWN(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU); +#endif #if defined(HAVE_LOCALECONV) && defined(ZTS) PHP_MSHUTDOWN(localeconv)(SHUTDOWN_FUNC_ARGS_PASSTHRU); #endif diff --git a/ext/standard/php_ext_syslog.h b/ext/standard/php_ext_syslog.h index 86b9704a4d..25b0e8424d 100644 --- a/ext/standard/php_ext_syslog.h +++ b/ext/standard/php_ext_syslog.h @@ -28,6 +28,7 @@ PHP_MINIT_FUNCTION(syslog); PHP_RINIT_FUNCTION(syslog); PHP_RSHUTDOWN_FUNCTION(syslog); +PHP_MSHUTDOWN_FUNCTION(syslog); PHP_FUNCTION(openlog); PHP_FUNCTION(syslog); diff --git a/ext/standard/syslog.c b/ext/standard/syslog.c index bde09e588a..b3057039e8 100644 --- a/ext/standard/syslog.c +++ b/ext/standard/syslog.c @@ -97,6 +97,7 @@ PHP_MINIT_FUNCTION(syslog) /* AIX doesn't have LOG_PERROR */ REGISTER_LONG_CONSTANT("LOG_PERROR", LOG_PERROR, CONST_CS | CONST_PERSISTENT); /*log to stderr*/ #endif + BG(syslog_device)=NULL; return SUCCESS; } @@ -109,22 +110,26 @@ PHP_RINIT_FUNCTION(syslog) } else { BG(syslog_started)=0; } - BG(syslog_device)=NULL; return SUCCESS; } PHP_RSHUTDOWN_FUNCTION(syslog) { - if (BG(syslog_device)) { - efree(BG(syslog_device)); - } #ifdef PHP_WIN32 closelog(); #endif return SUCCESS; } +PHP_MSHUTDOWN_FUNCTION(syslog) +{ + if (BG(syslog_device)) { + free(BG(syslog_device)); + } + return SUCCESS; +} + /* {{{ start_syslog */ static void start_syslog(TSRMLS_D) @@ -224,9 +229,9 @@ PHP_FUNCTION(openlog) return; } if (BG(syslog_device)) { - efree(BG(syslog_device)); + free(BG(syslog_device)); } - BG(syslog_device) = estrndup(ident, ident_len); + BG(syslog_device) = zend_strndup(ident, ident_len); openlog(BG(syslog_device), option, facility); RETURN_TRUE; } @@ -242,7 +247,7 @@ PHP_FUNCTION(closelog) closelog(); if (BG(syslog_device)) { - efree(BG(syslog_device)); + free(BG(syslog_device)); BG(syslog_device)=NULL; } RETURN_TRUE; -- 2.50.1