Fix an issues that mutexes are not unlocked in error cases.
Merge remote-tracking branch 'upstream/master'