This patch reduces the amount of code within the lock to only the critical sections. Signed-Off-By: Ayaz Abdulla