Skip to content

Commit

Permalink
use a net.ErrClosed when returning Accept from a closed server (quic-…
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann authored Jun 24, 2024
1 parent 2da1681 commit 8f11104
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ import (
)

// ErrServerClosed is returned by the Listener or EarlyListener's Accept method after a call to Close.
var ErrServerClosed = errors.New("quic: server closed")
var ErrServerClosed = errServerClosed{}

type errServerClosed struct{}

func (errServerClosed) Error() string { return "quic: server closed" }
func (errServerClosed) Unwrap() error { return net.ErrClosed }

// packetHandler handles packets
type packetHandler interface {
Expand Down
1 change: 1 addition & 0 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ var _ = Describe("Server", func() {
defer GinkgoRecover()
_, err := serv.Accept(context.Background())
Expect(err).To(MatchError(ErrServerClosed))
Expect(err).To(MatchError(net.ErrClosed))
close(done)
}()

Expand Down

0 comments on commit 8f11104

Please sign in to comment.