-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http/server.go: the server doesn't exit when the listener socket fd closed #68175
Comments
1.16 isn't a supported version. As far as we're aware, Serve does return on a closed listener: package main
import (
"log"
"net"
"net/http"
"time"
)
func main() {
lis, err := net.Listen("tcp", ":0")
if err != nil {
log.Fatalln(err)
}
svr := &http.Server{}
errc := make(chan error)
go func() {
errc <- svr.Serve(lis)
}()
time.Sleep(time.Second)
log.Println("close lis", lis.Close())
log.Println("serve err", <-errc)
} results in:
|
Yes, mostly the 1.16 behaves the same, the server will close after the listener was closed, but sometimes it won't. I can't reproduce it but it keeps happening. |
@seankhliao I know 1.16 is old, but does this issue remind you of any related issues? |
There are a bunch of possibly-related issued in the comment by gabyhelp above. |
Go version
go version go1.16 x86/amd64
Output of
go env
in your module/workspace:What did you do?
What did you see happen?
The server listens a random tcp port



after running a few days, the listen port is gone(can not find by netstat) and the fd socket is closed, but the process is still running and the goroutine still exists
What did you expect to see?
The text was updated successfully, but these errors were encountered: