Skip to content

Commit

Permalink
Fix bug #67764: fpm: syslog.ident does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
bukka committed Jun 19, 2022
1 parent 651e0cc commit e330f44
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions NEWS
Expand Up @@ -16,6 +16,9 @@ PHP NEWS
. Fixed bug #78139 (timezone_open accepts invalid timezone string argument).
(Derick)

- FPM:
. Fixed bug #67764 (fpm: syslog.ident don't work). (Jakub Zelenka)

- MBString:
. Fixed bug GH-8685 (pcre not ready at mbstring startup). (Remi)

Expand Down
7 changes: 1 addition & 6 deletions ext/standard/syslog.c
Expand Up @@ -120,11 +120,6 @@ PHP_MSHUTDOWN_FUNCTION(syslog)
return SUCCESS;
}

void php_openlog(const char *ident, int option, int facility)
{
openlog(ident, option, facility);
PG(have_called_openlog) = 1;
}

/* {{{ Open connection to system logger */
/*
Expand Down Expand Up @@ -161,7 +156,7 @@ PHP_FUNCTION(closelog)
{
ZEND_PARSE_PARAMETERS_NONE();

closelog();
php_closelog();
if (BG(syslog_device)) {
free(BG(syslog_device));
BG(syslog_device)=NULL;
Expand Down
12 changes: 12 additions & 0 deletions main/php_syslog.c
Expand Up @@ -32,6 +32,18 @@
#define syslog std_syslog
#endif

void php_openlog(const char *ident, int option, int facility)
{
openlog(ident, option, facility);
PG(have_called_openlog) = 1;
}

void php_closelog()
{
closelog();
PG(have_called_openlog) = 0;
}

#ifdef PHP_WIN32
PHPAPI void php_syslog(int priority, const char *format, ...) /* {{{ */
{
Expand Down
1 change: 1 addition & 0 deletions main/php_syslog.h
Expand Up @@ -37,6 +37,7 @@
BEGIN_EXTERN_C()
PHPAPI void php_syslog(int, const char *format, ...);
PHPAPI void php_openlog(const char *, int, int);
PHPAPI void php_closelog();
END_EXTERN_C()

#endif
2 changes: 1 addition & 1 deletion sapi/fpm/fpm/fpm_stdio.c
Expand Up @@ -88,7 +88,7 @@ int fpm_stdio_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
{
#ifdef HAVE_SYSLOG_H
if (fpm_globals.error_log_fd == ZLOG_SYSLOG) {
closelog(); /* ensure to close syslog not to interrupt with PHP syslog code */
php_closelog(); /* ensure to close syslog not to interrupt with PHP syslog code */
} else
#endif

Expand Down

0 comments on commit e330f44

Please sign in to comment.