Rename Bug
[1/1] from: ryanc::iesco-dms::com at: 6-Sep-2001 12:27
Hey Rebols,
here is a script I was testing sometime ago as a file
locker. It is based on the idea that renaming a file is
much like putting a file lock on a file, for access is
immediately changed at the OS level. While this sounds like
a great idea, while testing I discovered that View on
Windows 98 poops out with a strange security error during
this activity every once in awhile while undergoing multiple
accesses.
I was hoping you guys could try this on a few other OS's and
see how it works so I can prepare a more complete feedback
on this problem. Below is my test script. You will need to
create a file called %ctr that contains a zero. Start 10
instances of this script and see if they all complete
without error. If they all complete verify the counter file
reached 100000.
As they run they will display "L" before attempting to lock,
W
before attempting to write, and "U" before attempting to
unlock. Please report OS, and rebol version, and any error
message with the last state (L, W, U), . Unless
particularly interesting, go ahead and send those directly
to me, and I will compile them and post an FYI on the list.
--Ryan
REBOL [
file: %file-lock.r
purpose: {To demonstrate using rename as a file locking
mechanism.}
comments: {Create a file called %ctr that contains a
number such as 0.}
]
print "testing...."
loop 10000 [
prin newline
until [ prin "L" not error? try [ rename %ctr %busy ] ]
prin "W" write %busy 1 + old: load %busy
until [ prin "U" not error? try [ rename %busy %ctr ] ]
]