mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-05 13:17:36 +03:00
http3: return http.ErrServerClosed instead of quic.ErrServerClosed (#3900)
* - fix 3898 * fix gofumpt * - refactoring: inline serveListener in ServeListener - use ServeListener in s.serveConn - updated doc for the returned error --------- Co-authored-by: Marten Seemann <martenseemann@gmail.com>
This commit is contained in:
parent
e4fe28930a
commit
9acce3c6d9
1 changed files with 17 additions and 23 deletions
|
@ -262,13 +262,26 @@ func (s *Server) ServeQUICConn(conn quic.Connection) error {
|
||||||
// Make sure you use http3.ConfigureTLSConfig to configure a tls.Config
|
// Make sure you use http3.ConfigureTLSConfig to configure a tls.Config
|
||||||
// and use it to construct a http3-friendly QUIC listener.
|
// and use it to construct a http3-friendly QUIC listener.
|
||||||
// Closing the server does close the listener.
|
// Closing the server does close the listener.
|
||||||
|
// ServeListener always returns a non-nil error. After Shutdown or Close, the returned error is http.ErrServerClosed.
|
||||||
func (s *Server) ServeListener(ln QUICEarlyListener) error {
|
func (s *Server) ServeListener(ln QUICEarlyListener) error {
|
||||||
if err := s.addListener(&ln); err != nil {
|
if err := s.addListener(&ln); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err := s.serveListener(ln)
|
defer s.removeListener(&ln)
|
||||||
s.removeListener(&ln)
|
for {
|
||||||
return err
|
conn, err := ln.Accept(context.Background())
|
||||||
|
if err == quic.ErrServerClosed {
|
||||||
|
return http.ErrServerClosed
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
if err := s.handleConn(conn); err != nil {
|
||||||
|
s.logger.Debugf(err.Error())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var errServerWithoutTLSConfig = errors.New("use of http3.Server without TLSConfig")
|
var errServerWithoutTLSConfig = errors.New("use of http3.Server without TLSConfig")
|
||||||
|
@ -310,26 +323,7 @@ func (s *Server) serveConn(tlsConf *tls.Config, conn net.PacketConn) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := s.addListener(&ln); err != nil {
|
return s.ServeListener(ln)
|
||||||
return err
|
|
||||||
}
|
|
||||||
err = s.serveListener(ln)
|
|
||||||
s.removeListener(&ln)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Server) serveListener(ln QUICEarlyListener) error {
|
|
||||||
for {
|
|
||||||
conn, err := ln.Accept(context.Background())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
go func() {
|
|
||||||
if err := s.handleConn(conn); err != nil {
|
|
||||||
s.logger.Debugf(err.Error())
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractPort(addr string) (int, error) {
|
func extractPort(addr string) (int, error) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue