Move the lock from internal_{accept,connect,recv,send} to global level to protect more socket variables