Doc #54129 [Opn->Csd]: using LOCK_NB whilst aquiring a lock with flock() does work on windows

From: Date: Wed, 18 Nov 2020 15:01:54 +0000
Subject: Doc #54129 [Opn->Csd]: using LOCK_NB whilst aquiring a lock with flock() does work on windows
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18127@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54129&edit=1 ID: 54129 Updated by: cmb@php.net Reported by: scope at planetavent dot de Summary: using LOCK_NB whilst aquiring a lock with flock() does work on windows -Status: Open +Status: Closed Type: Documentation Problem Package: Filesystem function related Operating System: Windows Server 2008 (x64) PHP Version: 5.3.5 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: These issues have already been fixed in the meantime. Previous Comments: ------------------------------------------------------------------------ [2011-03-01 16:59:27] scope at planetavent dot de Description: ------------ The online documentation states that LOCK_NB to achieve a non-blocking lock-attempt is not supported on windows. The given test script, if started twice, just returns stating that the lock can not be aquired. Therefor, since it does not block, using LOCK_NB seems to work on windows and the documentation should be updated accordingly. If this is not the expected behaviour, the documentation should reflect the possible situations, where using LOCK_NB does indeed not work. Furthermore the statement "The automatic unlocking when the file's resource handle is closed was removed. Unlocking now always has to be done manually." should be checked. My test show that closing the file pointer with fclose() does release the lock. Test script: --------------- <?php $lockfile = 'dummy.lock'; $fp = fopen( $lockfile, 'w+' ); if ( !$fp ) { echo "unable to open lockfile\n"; exit; } if ( !flock( $fp, LOCK_EX | LOCK_NB ) ) { echo "unable to aquire lock\n"; exit; } sleep( 10 ); Expected result: ---------------- According to documentation, script should block (since LOCK_NB is not supported) Actual result: -------------- flock does not block ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=54129&edit=1

« previous php.doc.bugs (#18127) next »