php.net |  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
Votes:1
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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
Description:
------------
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)) {
    echo "ANOTHER INSTANCE RUNNING\n";
    exit(1);
}
else {
    touch(LOCK_FILE);
}

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

if(file_exists(LOCK_FILE)) {
    unlink(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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-05 04:17 UTC] kalle@php.net
I can reproduce this under Windows Vista with Apache 2
 [2008-10-26 19:15 UTC] jani@php.net
Is the webserver by any chance threaded?
See also http://php.net/flock 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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC