fix bug of crash in socket thread