common: Make InternalPeer (more) thread-safe