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