mutex shared host/peer sets, write-loop crash fix
Merge pull request #315 from subtly/bugfix

mutex shared host/peer sets, write-loop crash fix