Re: oops! flock() not work

From: Date: Mon, 22 May 2006 12:14:20 +0000
Subject: Re: oops! flock() not work
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-236624@lists.php.net to get a copy of this message
BTW. what i want is if one http session cannot obtain the lock, then it fails IMMEDIATELY, On 5/22/06, n. g. <nyvsld@gmail.com> wrote:
flock() with LOCK_NB not work under , nor does fopen() with 'x' mode, my php is compiled as an apache module, and apache is running in prefork mpm. php version is 5.1.2 my code is <?php $haslock=0; if($lock=fopen('LOCK','w')){ if(flock($lock,LOCK_EX|LOCK_NB))$has_lock=1; } if($has_lock){ //do something which should always be only one process } ?> or <?php $has_lock=0; $lock=fopen('LOCK','x'); if($lock)$has_lock=1; if(has_lock){ // do something } both of them wont work. however cli mode works well. any clue? TIA.
-- Tomorrow will be a good day :-)

« previous php.general (#236624) next »