tcp: fix possible socket refcount problem