Skip to content

Commit 4537138

Browse files
committed
Revert "Make BG(syslog_device) per request"
This reverts commit b0d7b12. This change wasn't quite right: I noticed only now that the RSHUTDOWN function is #ifdef PHP_WIN32 and I'm not fully convinced that ifdef can be removed: syslog might also be used by error logging in FPM for example, in which case we probably shouldn't be closing the log here. Generally it's unclear how the openlog() functionality exposed by PHP is supposed to interact with openlog() uses by SAPIs. For now I'll just revert this change and let it leak across requests.
1 parent 981fdd9 commit 4537138

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

ext/standard/syslog.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ PHP_MINIT_FUNCTION(syslog)
9191
/* AIX doesn't have LOG_PERROR */
9292
REGISTER_LONG_CONSTANT("LOG_PERROR", LOG_PERROR, CONST_CS | CONST_PERSISTENT); /*log to stderr*/
9393
#endif
94+
BG(syslog_device)=NULL;
9495

9596
return SUCCESS;
9697
}
@@ -107,16 +108,16 @@ PHP_RINIT_FUNCTION(syslog)
107108
PHP_RSHUTDOWN_FUNCTION(syslog)
108109
{
109110
closelog();
110-
if (BG(syslog_device)) {
111-
efree(BG(syslog_device));
112-
BG(syslog_device) = NULL;
113-
}
114111
return SUCCESS;
115112
}
116113
#endif
117114

118115
PHP_MSHUTDOWN_FUNCTION(syslog)
119116
{
117+
if (BG(syslog_device)) {
118+
free(BG(syslog_device));
119+
BG(syslog_device) = NULL;
120+
}
120121
return SUCCESS;
121122
}
122123

@@ -146,9 +147,9 @@ PHP_FUNCTION(openlog)
146147
ZEND_PARSE_PARAMETERS_END();
147148

148149
if (BG(syslog_device)) {
149-
efree(BG(syslog_device));
150+
free(BG(syslog_device));
150151
}
151-
BG(syslog_device) = estrndup(ident, ident_len);
152+
BG(syslog_device) = zend_strndup(ident, ident_len);
152153
if(BG(syslog_device) == NULL) {
153154
RETURN_FALSE;
154155
}
@@ -165,8 +166,8 @@ PHP_FUNCTION(closelog)
165166

166167
closelog();
167168
if (BG(syslog_device)) {
168-
efree(BG(syslog_device));
169-
BG(syslog_device) = NULL;
169+
free(BG(syslog_device));
170+
BG(syslog_device)=NULL;
170171
}
171172
RETURN_TRUE;
172173
}

0 commit comments

Comments
 (0)