Fixed connection segmentation fault in multi-thread