Merge pull request #1094 from duncanka/master

Fixed server hang issue (lock not always released)