[REBOL] Re: Double trouble
From: petr:krenzelok:trz:cz at: 27-Jun-2001 20:47
> > get-lock: func [path file-name][
> > semaphore: sem-port-spec path file-name
>
> It looks to me, that 'semaphore will "leak" to the global context,
although
> you didn't intend that
maybe ....
> ; file doesn't exist, or does exist, but semaphore can be closed
> (dead one)
> >
> > either not exists? semaphore [
> > ; store pair of file-name, opened port
> > append locked semaphore
> > append locked open/new/direct semaphore
>
> looks like the lock isn't exclusive, there is a possibility for two
> "concurrent" scripts to obtain the semaphore
there is not imo :-) 'semaphore holds e.g. %/C/my-dir/my-file-name.sem. I
store pairs of path + opened port, because Rebol interpreter will lock the
file, untill I close the port. And that is imo the only problem - the script
scrash - it will prevent another instances of Rebol from deleting the
semaphore file, because the interpreter still holds OS locks, untill you
quit it ...
> I have got an exclusive file-based multiplatform locking mechanism, but it
> is a part of a larger script and I should rewrite it as stand-alone before
> it can be presented here...
Great - I would like to see it, especially in regards to Unix, where it does
seem to be unressolvable. Even if your app uses proper kernel locking,
another one can't do so and hence can delete your file. I don't understand
why it is that way ...
-pekr-