PHP 4.0 Bug #5122: db.c - call to flock() - lock relased too early when close() is called

From: Date: Mon, 19 Jun 2000 12:01:05 +0000
Subject: PHP 4.0 Bug #5122: db.c - call to flock() - lock relased too early when close() is called
Groups: php.dev 
Request: Send a blank email to php-dev+get-21719@lists.php.net to get a copy of this message
From: wcampbell@chello.com Operating system: Solaris 2.6 PHP version: 4.0.0 Release PHP Bug Type: DBM/DBA related Bug description: db.c - call to flock() - lock relased too early when close() is called 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.

« previous php.dev (#21719) next »