Posted by Sjoerd on 05/04/06 19:30
William Gill wrote:
> To prevent two users from
> getting the same serial number I put a delay loop in the script using
> while(file_exists(tracknum.lock)
You have a typical race condition:
You wait until the file is deleted and then create it. Suppose that the
file is deleted and created immediatly after file_exists. The file
would be created by another process, e.g. another user requesting this
page. After the while() loop, you assume that the file still does not
exist in the next instruction, which is an unfair assumption.
Navigation:
[Reply to this message]
|