|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46197 Problems with file_exists() and multiple instances
Submitted: 2008-09-29 15:12 UTC Modified: 2008-11-03 01:00 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: henrique dot grolli at gmail dot com Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5.2.6 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: henrique dot grolli at gmail dot com
New email:
PHP Version: OS:


 [2008-09-29 15:12 UTC] henrique dot grolli at gmail dot com
Well, better explained when seeing the code.

Not acting as expected via web browser as the both instances execute as the lock file was not created by another instance but doing it well via shell console.

Same problem using clearstatcache() function.

Reproduce code:
// LOCK_FILE was defined to /tmp/test.lock
// creating the lock file
if(file_exists(LOCK_FILE)) {
else {

/* any action that takes time*/
echo "running\n";
sleep(5); // simulating slow scripts
echo "done\n";

if(file_exists(LOCK_FILE)) {
else {
    echo "I think someone deleted the lock file\n";

Expected result:
To see "running\ndone\n" in one instance, and "ANOTHER INSTANCE RUNNING\n" if another instance try to execute at the same time.

Actual result:
Via shell everything works as well but via web browser both instances run as the lock file doesnt exist.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-05 04:17 UTC]
I can reproduce this under Windows Vista with Apache 2
 [2008-10-26 19:15 UTC]
Is the webserver by any chance threaded?
See also for proper locking method.
 [2008-11-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Jan 19 06:01:23 2021 UTC