Properly synchronize main and worker thread when peer_data has to be reallocated.