Branch: Tag:

2018-05-28

2018-05-28 09:59:47 by Martin Karlgren <marty@roxen.com>

Configuration.lock_file: Avoid trying to unlock locks in the module where locking failed.

Also made the unlocking of previous locks more explicit for readability.
Fixes an assertion failure in module.unregister_lock.

2163:    DAVLock lock = DAVLock(locktoken, path, recursive, lockscope, locktype,    expiry_delta, owner);    lock->is_file = is_file; +  array(array(string|function)) successful_locks = ({});    foreach(location_module_cache||location_modules(),    [string loc, function func])    {
2183:    mapping(string:mixed) lock_error =    function_object(func)->lock_file(subpath, lock, id);    if (lock_error) { -  // Failure. Unlock the new lock. -  foreach(location_module_cache||location_modules(), -  [string loc2, function func2]) +  // Failure. Unlock the new lock in modules where it was +  // registered successfully. +  foreach(reverse(successful_locks), [string loc2, function func2])    {    if (has_prefix(path, loc2)) {    // path == loc2 + subpath.
2197:    mapping(string:mixed) ret =    function_object(func2)->unlock_file("/", lock, id);    } -  if (func == func2) break; +     }    // destruct(lock);    TRACE_LEAVE(sprintf("Lock error: %O", lock_error));    return lock_error;    } -  +  +  successful_locks += ({ ({ loc, func }) }); +     TRACE_LEAVE("Ok.");    if (function_object(func)->webdav_opaque) break;    }