note 51988 deleted from function.flock by danbrown

From: Date: Mon, 18 May 2009 00:43:14 +0000
Subject: note 51988 deleted from function.flock by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155418@lists.php.net to get a copy of this message
Note Submitter: eddi.to-grip.de ---- When using a multithreaded server like apache with worker.c on Linux you can use follow lines: <?php function fprotect($key, $file, $content=FALSE, $fopen_mode='w', $chmod=0600, $sem_mode=0600 ) { $semaphor=sem_get($key,1,$sem_mode); sem_acquire($semaphor); if($content) { if($dat=fopen($file,$fopen_mode)) { chmod($file,$chmod); fputs($dat,$content); fclose($dat); } else return(FALSE); } else return(file_get_contents($datei)); sem_release($semaphor); return(TRUE); } ?> Also this should work instead of flock() using a non-multithreaded server on Linux. Greetings form Berlin :)

« previous php.notes (#155418) next »