Add locking to deadlock detection
Merge
Fix merge issue
Merge pull request #172 from Metaswitch/deadlock

[Reviewer Andy] Add locking to deadlock detection