Reply to Re: question about using lock files

Your name:

Reply:


Posted by Bob_M (remove X for email) on 05/05/06 01:51

On Thu, 04 May 2006 14:56:30 GMT, William Gill <noreply@gcgroup.net>
wrote:

>I have a PHP user form that I supply a serial number for response
>tracking. The serial number is kept in a simple text file
>(tracknum.dat). When someone submits the form, PHP reads the number,
>increments it, writes the new number to the file, and sends the number
>back to the user for tracking purposes. To prevent two users from
>getting the same serial number I put a delay loop in the script using
>while(file_exists(tracknum.lock). tracknum.lock is created before
>tracknum.dat is opened, and deleted after the new serial number is
>written. This seems to work, but it could cause an infinite loop if for
>some reason the lock file doesn't get deleted by the previous user. Am I
>being paranoid about the possible infinite loop? Is there a smarter way
>to do this?
>
>Thanks
>
>Bill
Why not try "flock"ing the file(s). YOUR process will wait for the
other (owner) task to release it before continuing.

B

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация