Bug #80737 [NEW]: blocking flock() with timeout

From: Date: Fri, 12 Feb 2021 10:50:49 +0000
Subject: Bug #80737 [NEW]: blocking flock() with timeout
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232084@lists.php.net to get a copy of this message
From: maggus dot staab+php at googlemail dot com Operating system: ubuntu16/18/20 PHP version: 7.4.15 Package: Streams related Bug Type: Bug Bug description:blocking flock() with timeout Description: ------------ I did a lot of research regarding flock() and timeouts. I found workarounds using pcntl_signal/alarm which only work on the CLI: https://github.com/php-lock/lock/blob/8b254edfe1400a733e3cde571e981687e6f6d804/classes/util/PcntlTimeout.php#L68-L94 our current workaround is to use LOCK_NB in a loop + usleep() until it succeeds, which feels rather hacky and wastes a lot of IO especially on NFS based volumes. This was the only way I found to get it working in a web sapi. wouldn't it be possible to e.g. take a stream_set_timeout() into account for the blocking flock() case? Test script: --------------- $fd = fopen("/path/to/my/file", 'c+'); stream_set_timeout($fd, 0, 1); var_dump(flock($fd, LOCK_EX)); // should return false on timeout $info = stream_get_meta_data($fd); var_dump($info); // should report a timeout -- Edit bug report at https://bugs.php.net/bug.php?id=80737&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80737&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80737&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80737&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80737&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80737&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80737&r=support Expected behavior: https://bugs.php.net/fix.php?id=80737&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80737&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80737&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80737&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80737&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80737&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80737&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80737&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80737&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80737&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80737&r=mysqlcfg

« previous php.bugs (#232084) next »