[peer_handler] Take the peers lock before getting messages to send