Merge pull request #3946 from dgquintas/wut

Fixed an inexplicable wrong handling of a lock