Fixed subtle bug introduced by MR #1499 where lock_unlock was called on a lock that was not locked.
As the title says. While deleting some code, a bit of a block was missed. That caused multiple threads to simultaneously try to unlock a lock that was not even locked. That created trouble.