I noticed this problem when some of the integration tests I was running were spuriously failing if the same port was used multiple times. I narrowed it down to the server not actually being closed after Close or Shutdown returns so I created this issue.
The text was updated successfully, but these errors were encountered:
changed the title
net/http: Server still handling connections after Close (or Shutdown) returnsDec 11, 2019
I can reproduce this reliably locally, but I have to increase the number of parallel requests to 10. After some more investigation, it does look like the handler is indeed invoked after we called server.Close(). I'm not an expert on internal/poll/fd_unix.go, so it's hard for me to say if this is a bug, or if TCP file descriptors just aren't expected to be synchronously closed.
I cannot reproduce this with net.Listen / Accept on my own, so I wonder if it is related to our retry semantics when accepting a connection in a http server.
I can reproduce on stock go installation also increasing parallel requests to 10 and I can not reproduce on the fix branch build.
To avoid Get error! Get "http://127.0.0.1:8081": dial tcp 127.0.0.1:8081: connect: cannot assign requested address due to paraller requests increase I've changed client to talk over multiple localhost IPs: