Fix for locking issues in redmine/6334