net: do not bind TCP server after close has run
Checklist
-
tests and code linting passes -
a test and/or benchmark is included -
the commit message follows commit guidelines
Affected core subsystem(s)
- net
Description of change
Currently, calling listen() on a Server with a hostname, causes the server to perform a DNS lookup. Calling close() on the Server, before the DNS is complete and a handle is set, makes .close() a noop and when the DNS lookup returns, it binds the TCP socket.
Instead, when close() is called on a Server, whose DNS request is still in progress - mark the Server as closed, and do not store the handle when the DNS request is complete.
Fixes #6188 (closed)