http3: return http.ErrServerClosed for ServeQUICConn after Server.Close (#5095)

This commit is contained in:
Marten Seemann
2025-04-29 18:05:14 +08:00
committed by GitHub
parent 5daf5b6535
commit 41cc01890d
2 changed files with 6 additions and 0 deletions

View File

@@ -264,6 +264,11 @@ func (s *Server) decreaseConnCount() {
// ServeQUICConn serves a single QUIC connection.
func (s *Server) ServeQUICConn(conn quic.Connection) error {
s.mutex.Lock()
if s.closed {
s.mutex.Unlock()
return http.ErrServerClosed
}
s.init()
s.mutex.Unlock()

View File

@@ -883,6 +883,7 @@ var _ = Describe("Server", func() {
serv := &Server{}
Expect(serv.Close()).To(Succeed())
Expect(serv.ListenAndServeTLS(testdata.GetCertificatePaths())).To(MatchError(http.ErrServerClosed))
Expect(serv.ServeQUICConn(nil)).To(MatchError(http.ErrServerClosed))
})
It("handles concurrent Serve and Close", func() {