fix race condition in bsim socket