fix the socket caos problem by adding mutex