Fix threading issues with peer setting.

Signed-off-by: Robert Xu <robxu9@gmail.com>