Fixed server hang issue (lock not always released)
Fixed previous fix
Merge pull request #1094 from duncanka/master

Fixed server hang issue (lock not always released)