php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61492 flock for php 5.3.2 - regression
Submitted: 2012-03-23 16:27 UTC Modified: 2013-01-09 01:59 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: spamik at yum dot pl Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.3.10 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: spamik at yum dot pl
New email:
PHP Version: OS:

 

 [2012-03-23 16:27 UTC] 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 :(


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-23 16:42 UTC] spamik at yum dot pl
"The automatic unlocking when the file's resource handle is closed was removed. 
Unlocking now always has to be done manually."
 [2012-03-26 00:43 UTC] aharvey@php.net
The manual sums this up: the behaviour was (intentionally) changed in 5.3.2, and 
isn't going to change again.
 [2012-03-26 00:43 UTC] aharvey@php.net
-Status: Open +Status: Not a bug -Type: Feature/Change Request +Type: Bug -Package: *General Issues +Package: Streams related
 [2013-01-09 01:59 UTC] spamik at yum dot pl
right, all changes are for the better...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC