Re: PHP fopen() bug + solution

From: Date: Fri, 08 Nov 2002 08:14:58 +0000
Subject: Re: PHP fopen() bug + solution
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-123331@lists.php.net to get a copy of this message
At 00:51 08.11.2002, Charles Wiltgen said: --------------------[snip]-------------------- >Example: while(!file_exists("index.php") { clearstatcache(); } > while(filesize("index.php" < 10) { clearstatcache(); } --------------------[snip]-------------------- To be more effective, and to allow the OS to do something else while you're waiting at the file, your script should sleep for some microseconds... this will release the time slice your script is occupying and allow other things to happen, without having the cpu going up to 100%. while(!file_exists("index.php") { usleep(100); clearstatcache(); } while(filesize("index.php" < 10) { usleep(100); clearstatcache(); } This will sleep for 0.1 seconds, not really notable. Note that I put the call to clearstatcache() _after_ the sleep... -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#123331) next »