Daniel Shahaf <[email protected]> writes:
> Why does svn_io_file_lock2() have a retry loop?
>
> The reason given in the code is that some consumer of libsvn_fs wants to run
> a critical section while holding a lock in each of two FSFS filesystems. In
> that case, why isn't the fix just to tell the consumer to, when wanting to
> lock N filesystems, to always lock them in a well-defined order?
First, the knowledge about the locks is entirely within the thread at
present, each thread has no knowledge of what other threads are doing.
You would need to introduce some sort of per-process lock handler.
Secondly, from the comment in the code:
Process 1 Process 2
--------- ---------
thread 1: get lock in repos A
thread 1: get lock in repos B
thread 2: block getting lock in repos A
thread 2: try to get lock in B *** deadlock ***
when each process takes the first lock it may not know that it will want
the second lock.
--
Philip