Do not enter critical section if not necessary

Related to rhbz#1051198