On 2017-04-18 17:00, Ken Simon wrote:
net/http.Server.Close() only exists in golang 1.8... I'm stuck in 1.7
right now so I can't use that.
No, but you can do something equivalent with either a connection manager
like in the various "graceful" libraries or simply (as also suggested)
disable keepalives.
Your later comment about switching the handler doesn't apply to my case
unfortunately, in the real code, I'm writing tests encapsulate the
behavior of starting and stopping the server.
That was not my comment. However, the issue AFAICS is a combination of
how stuff works server-side and client side.
Server side a HTTP server (unless you call Close()/Shutdown() in Go 1.8
or manually track connections and close them) will allow individual
connections to live on after the listener is closed.
Even if you start a new server to listen on the same address.
At the same time - client side - you client will not create a new
connection the same host if there's already a valid connection to that
host in the connection pool.
So as long as the old connection lives on (you should be able to see it
with netstat or similar) the second GET will go on the same TCP
connection and hit the same handler in the same server which hasn't yet
been garbage collected.
/Peter
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.