fix accept and read race condition