use proper value to check the log_source handle

This commit is contained in:
Anatol Belski 2015-03-11 19:07:46 +01:00
parent d5f2b4b398
commit cf4c60b372
2 changed files with 6 additions and 8 deletions

View file

@ -34,6 +34,8 @@ void php_win32_core_globals_ctor(void *vg)
memset(wg, 0, sizeof(*wg)); memset(wg, 0, sizeof(*wg));
wg->mail_socket = INVALID_SOCKET; wg->mail_socket = INVALID_SOCKET;
wg->log_source = INVALID_HANDLE_VALUE;
} }
void php_win32_core_globals_dtor(void *vg) void php_win32_core_globals_dtor(void *vg)

View file

@ -61,9 +61,9 @@
void closelog(void) void closelog(void)
{ {
if (PW32G(log_source)) { if (INVALID_HANDLE_VALUE != PW32G(log_source)) {
DeregisterEventSource(PW32G(log_source)); DeregisterEventSource(PW32G(log_source));
PW32G(log_source) = NULL; PW32G(log_source) = INVALID_HANDLE_VALUE;
} }
if (PW32G(log_header)) { if (PW32G(log_header)) {
efree(PW32G(log_header)); efree(PW32G(log_header));
@ -86,7 +86,7 @@ void syslog(int priority, const char *message, ...)
DWORD evid; DWORD evid;
/* default event source */ /* default event source */
if (!PW32G(log_source)) if (INVALID_HANDLE_VALUE == PW32G(log_source))
openlog("php", LOG_PID, LOG_SYSLOG); openlog("php", LOG_PID, LOG_SYSLOG);
switch (priority) { /* translate UNIX type into NT type */ switch (priority) { /* translate UNIX type into NT type */
@ -122,11 +122,7 @@ void syslog(int priority, const char *message, ...)
void openlog(const char *ident, int logopt, int facility) void openlog(const char *ident, int logopt, int facility)
{ {
if (PW32G(log_source)) {
closelog(); closelog();
}
efree(PW32G(log_header));
PW32G(log_source) = RegisterEventSource(NULL, "PHP-" PHP_VERSION); PW32G(log_source) = RegisterEventSource(NULL, "PHP-" PHP_VERSION);
spprintf(&PW32G(log_header), 0, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid()); spprintf(&PW32G(log_header), 0, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid());