net/http: Server should not be reusable #24047
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Once a
*http.Server
is closed, it should not be reusable via*http.Server.Serve
. IfServe
is called on a closed*http.Server
, it should returnErrServerClosed
.My reasoning behind this proposed change is that presently, there is subtle unexpected behaviour in what I think are pretty standard Go http servers. They have the following structure.
The problem with the above structure is the program may receive a os signal before the server has begun serving. It will call
Close()
orShutdown()
on the server. Then, the program could exit which means everything worked out fine but another possibility is that now the server begins serving. This is hypothetical and unlikely but if it does happen, the Server may receive a request and begin processing. This would be unexpected behaviour imo.If the program originally called
Close()
, it would be unexpected for a new request to be accepted after the server is closed. If the program calledShutdown()
, then the program may exit with a request in flight which would not be a graceful shutdown.Now, I do not think we can change this behaviour because it is possible existing programs rely on it, perhaps Go 2?
The text was updated successfully, but these errors were encountered: