fix infinity loop when client close the socket