> Function chat2file($filename, $str) {
>   $fp = fopen("chats/$filename", "a");
>   fputs($fp, $str);
>   close($fp);
> }

So long as $str is less than, errr, 8K?, this is good on Linux, as the
append will be atomic.

You would want flock here if it's not Linux, or if it wasn't "a".

> Function file2chat($filename) {
>   if(file_exists("chats/$filename")) {
>     $fd = fopen("chats/$filename", "r");
>     flock($fd, LOCK_UN);

You don't need to lock for reading at all.  You really don't care if 2
people read at once.

Disclaimer:  I *THINK* it's (Linux+append && <8K == atomic)...

WARNING [EMAIL PROTECTED] address is an endangered species -- Use
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to