gsocket: Fix use-after-close
To fix (mostly theoretical) race conditions where another thread may have just allocated a new file-descriptor, and we end up using a file-descriptor that doesn't belong to us.
Caught by Application Verifier (on Windows).
Edited by Ole André Vadla Ravnås