Fixed unbalanced semaphore lock