Patch: General locking (was Possible deadlock and solution)

Matthias Andree matthias.andree at gmx.de
Wed Oct 2 05:19:52 CEST 2002


On Tue, 01 Oct 2002, David Relson wrote:

> I do have a question on the release list code.  I notice that locks are 
> released in reverse order of their acquisition.  Is the order 
> important?  Would there be any problem in reversing the order?

You'd usually clean up in the reverse order of allocation, last
allocated, first freed. It's also simpler code-wise ;-)

> The reason that I ask is that Eric's multi-list code uses a singly linked 
> list, which has a distinct order for the processing.  Merging your code and 
> his will be easy if the order doesn't matter, a bit more difficult if the 
> order _does_ matter.

singly-linked lists stink <ducks & runs for cover>

Seriously: The lock release order does not matter. The other application
can only proceed if ALL locks are freed, and it does not matter which
lock is the last one to be released.

The important thing is to obtain the whole set of locks, and release all
the locks we got right away if ANY lock failed. Acquiring all the locks
in the same place is more a maintenance issue than a necessity, but
you'd have a hard time tracking down deadlocks if you spread the locks
around, and if you did not properly roll back the locks (release them),
weee... I'd rather not like to debug such code.

-- 
Matthias Andree



More information about the bogofilter-dev mailing list