zenphoto/zenphoto — pull request #87 by d4gurasu (2012-11-04 11:06:16+00:00)
Title: Uniform lock distribution and found two existing bugs(not fixed).

Fast and light sequential lock id selection mod concurrency.

I store the index in a file atomically.
This is MUCH faster than my previous version using getOption/setOption.
On a very old cpu it adds less than 0.5 milliseconds to grabbing the lock.

If file access fails somehow, it falls back on random.
-----------------------------
This is integrating into the present class.

I found two other serious bugs in the present implementation while testing this.
1 is realted to the options menu not working and another to unlock the wrong locks!

I did NOT fix these. I will report them in separate reports.

In order to test I set the option manually. I try to test my work, that it at least runs more less. Of course things can always slip through.

Personally I would not get the lock id in the constructor since it should be obtained as close to locking as possible. In practice, it's probably irrelevant though, so I tried to change as little as possible basically while getting this feature in.