[php-src] Issue #8923: error_log on Windows can hold the file write lock
| From: | neil-pearce | Date: | Tue, 05 Jul 2022 11:06:10 +0000 |
| Subject: | [php-src] Issue #8923: error_log on Windows can hold the file write lock | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241858@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8923
Author: neil-pearce
### Description
The problem can only be seen on a very busy Windows box. If error_log is called then the lock is not
immediately released by the file close but at a time that "depends upon available system
resources". This is a 'feature' of the Windows function LockFileEx. The problem has
already been addressed in the routine ps_files_close (in the file mod_files.c):
```
static void ps_files_close(ps_files *data)
{
if (data->fd != -1) {
#ifdef PHP_WIN32
/* On Win32 locked files that are closed without being explicitly unlocked
will be unlocked only when "system resources become available". */
flock(data->fd, LOCK_UN);
#endif
close(data->fd);
data->fd = -1;
}
}
```
The same logic should be implemented in the routine php_log_err_with_severity (in main.c).
### PHP Version
All versions
### Operating System
Windows