On 06/28/2012 06:22 PM, Jakub Filak wrote:
If a problem directory is locked by a process and the process tries to lock directory again the function dd_lock() fals to infinite loop. In this case the function get_and_set_lock() correctly recognizes that a lock is owned by the process but the function returns an error value 0. The correct returned value is 1 because a directory is locked by the process thus lock was successful.
No, it is not. If we will return "yes we got the lock" indication then the caller will eventually unlock the dir. Which will leave it UNLOCKED but the first locking party doesn't know it and still believes that it has a lock. In other words, locking is presently not designed to be recursive. Just letting lock succeed is not enough to make it recursive: we need to maintain a recursion counter somewhere. I caught a locking bug (missing unlock) when this code path was triggered while I was testing one of my changes. -- vda
