php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5122 db.c - call to flock() - lock relased too early when close() is called
Submitted: 2000-06-19 14:01 UTC Modified: 2000-10-02 22:28 UTC
From: wcampbell at chello dot com Assigned:
Status: Closed Package: DBM/DBA related
PHP Version: 4.0.0 Release OS: Solaris 2.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
14 + 4 = ?
Subscribe to this entry?

 
 [2000-06-19 14:01 UTC] wcampbell at chello dot com
The function php_dbm_open() in db.c contains the following lines ...

		if (lockfd) {
			flock(lockfd,LOCK_EX);
			close(lockfd);
		} else {
			php_error(E_WARNING, "Unable to establish lock: %s",filename);
		}

I don't think that this will achieve what is intended - at least not under Solaris where PHP implements flock() in terms of fnctl(). (I strongly suspect that this problem will also show itself under other versions of UNIX).

The reason is that the lock will be released immediately after it is obtained by the call to close().

I noticed this problem under PHP 3.0.12 but I have looked at the source code of PHP 4.0.0 to verify that this problem hasn't been fixed there.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-20 04:02 UTC] sniper@php.net
Does this problem still persist with more recent version of php (from CVS or http://snaps.php.net) ??

--Jani
 [2000-09-03 19:49 UTC] sniper@php.net
Could you provide some sample script to test this..?

--Jani
 [2000-10-02 22:28 UTC] sniper@php.net
No feedback.

--Jani
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 14:01:29 2024 UTC