Edit report at https://bugs.php.net/bug.php?id=61492&edit=1

 ID:                 61492
 User updated by:    spamik at yum dot pl
 Reported by:        spamik at yum dot pl
 Summary:            flock for php 5.3.2 - regression
 Status:             Open
 Type:               Feature/Change Request
 Package:            *General Issues
 PHP Version:        5.3.10
 Block user comment: N
 Private report:     N

 New Comment:

"The automatic unlocking when the file's resource handle is closed was removed. 
Unlocking now always has to be done manually."


Previous Comments:
------------------------------------------------------------------------
[2012-03-23 16:27:16] spamik at yum dot pl

Description:
------------
http://www.php.net/manual/en/function.flock.php

"On versions of PHP before 5.3.2, the lock is released also by fclose() (which 
is also called automatically when script finished)."

This is huge regression. I've used with success file locking to check if 
another 
instance of file is already running putting code like this in front of the 
script or append_script

$h55 = fopen($_SERVER['argv'][0],"r");
while(!flock($h55, LOCK_EX + LOCK_NB )) {
echo "cant get lock, die\n";
die();
}

or

$h55 = fopen($_SERVER['argv'][0],"r");
while(!flock($h55, LOCK_EX + LOCK_NB )) {
echo "cant get lock, waiting 10s\n";
sleep(10);
}

I've used it for scripts that had variable running time with a crontab. Now it 
is all impossible thanks to that change :(



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61492&edit=1

Reply via email to