[REBOL] Re: Concurrent access to data file
From: brett:codeconscious at: 19-Feb-2001 22:58
Hi Christophe,
Firstly I assume this bit of code is going to be running on each of the 80
Pcs, not as some sort of server process. Is this the case?
(1) If so, I think your proposed method is not going give you any of the
protection you expect.
There could be a "window of opportunity" for another process to get in even
though it should not.
The weakness is that two processes could both succeed in "reserving" the
token.
(2) The other problem is the possibility that a program will fail due to an
error yet leave the token in place so that other processes believe it is
locked.
I suspect that you really need to trust file locking, but the problem is I
haven't been able to work out if there is a way to get Rebol to lock files.
I attempted this:
x: open/write/direct/binary %lock-file.dat
and again in another rebol session which did not return an error so it seems
that Rebol appears to opening the file without exclusive write locking.
With them still open I attempted to open the file with Wordpad.exe. Wordpad
did not open the file - complaining that another application had the file
open - correct. To verify I close the opened ports and tried wordpad.exe
again - this time it opened.
So I believe that it would be good if rebol had file locking abilities.
However I found that if you open a file like I did above, and try to rename
it you will cause an error - indicating the file is in use. This was
confirmed when I belatedly read my site :-\ below
http://www.codeconscious.com/rebol/rebol-net.html#Filelocking
This indicates that a good idea might be for the client to open a tcp/ip
connection with a rebol process on the server. This way if the client
process dies, the connection should (?) timeout - thus dealing with problem
(2). I haven't tried it so ...
Hope it helps.
Brett.
----- Original Message -----
From: "CRS - Psy Sel/SPO, COUSSEMENT Christophe, CPN"
<[COUSSEMENT--C--ITC--mil--be]>