diff --git a/integrationtests/self/handshake_test.go b/integrationtests/self/handshake_test.go index e86e2595..aaa7702d 100644 --- a/integrationtests/self/handshake_test.go +++ b/integrationtests/self/handshake_test.go @@ -311,7 +311,7 @@ var _ = Describe("Handshake tests", func() { _, err := dial() Expect(err).To(HaveOccurred()) - Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.ServerBusy)) + Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.ConnectionRefused)) // now accept one session, freeing one spot in the queue _, err = server.Accept(context.Background()) @@ -324,7 +324,7 @@ var _ = Describe("Handshake tests", func() { _, err = dial() Expect(err).To(HaveOccurred()) - Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.ServerBusy)) + Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.ConnectionRefused)) }) It("removes closed connections from the accept queue", func() { @@ -340,7 +340,7 @@ var _ = Describe("Handshake tests", func() { _, err = dial() Expect(err).To(HaveOccurred()) - Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.ServerBusy)) + Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.ConnectionRefused)) // Now close the one of the session that are waiting to be accepted. // This should free one spot in the queue. @@ -354,7 +354,7 @@ var _ = Describe("Handshake tests", func() { _, err = dial() Expect(err).To(HaveOccurred()) - Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.ServerBusy)) + Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.ConnectionRefused)) }) }) diff --git a/internal/qerr/error_codes.go b/internal/qerr/error_codes.go index 7fee9c48..1e1cf7ba 100644 --- a/internal/qerr/error_codes.go +++ b/internal/qerr/error_codes.go @@ -13,7 +13,7 @@ type ErrorCode uint64 const ( NoError ErrorCode = 0x0 InternalError ErrorCode = 0x1 - ServerBusy ErrorCode = 0x2 + ConnectionRefused ErrorCode = 0x2 FlowControlError ErrorCode = 0x3 StreamLimitError ErrorCode = 0x4 StreamStateError ErrorCode = 0x5 @@ -53,8 +53,8 @@ func (e ErrorCode) String() string { return "NO_ERROR" case InternalError: return "INTERNAL_ERROR" - case ServerBusy: - return "SERVER_BUSY" + case ConnectionRefused: + return "CONNECTION_REFUSED" case FlowControlError: return "FLOW_CONTROL_ERROR" case StreamLimitError: diff --git a/qlog/types.go b/qlog/types.go index ca782513..236b6633 100644 --- a/qlog/types.go +++ b/qlog/types.go @@ -303,8 +303,8 @@ func (e transportError) String() string { return "no_error" case qerr.InternalError: return "internal_error" - case qerr.ServerBusy: - return "server_busy" + case qerr.ConnectionRefused: + return "connection_refused" case qerr.FlowControlError: return "flow_control_error" case qerr.StreamLimitError: diff --git a/qlog/types_test.go b/qlog/types_test.go index 4d1eb9fb..0be04099 100644 --- a/qlog/types_test.go +++ b/qlog/types_test.go @@ -100,7 +100,7 @@ var _ = Describe("Types", func() { It("has a string representation for transport errors", func() { Expect(transportError(qerr.NoError).String()).To(Equal("no_error")) Expect(transportError(qerr.InternalError).String()).To(Equal("internal_error")) - Expect(transportError(qerr.ServerBusy).String()).To(Equal("server_busy")) + Expect(transportError(qerr.ConnectionRefused).String()).To(Equal("connection_refused")) Expect(transportError(qerr.FlowControlError).String()).To(Equal("flow_control_error")) Expect(transportError(qerr.StreamLimitError).String()).To(Equal("stream_limit_error")) Expect(transportError(qerr.StreamStateError).String()).To(Equal("stream_state_error")) diff --git a/server.go b/server.go index 65c78a9a..503d9e37 100644 --- a/server.go +++ b/server.go @@ -400,7 +400,7 @@ func (s *baseServer) handleInitialImpl(p *receivedPacket, hdr *wire.Header) erro if queueLen := atomic.LoadInt32(&s.sessionQueueLen); queueLen >= protocol.MaxAcceptQueueSize { s.logger.Debugf("Rejecting new connection. Server currently busy. Accept queue length: %d (max %d)", queueLen, protocol.MaxAcceptQueueSize) go func() { - if err := s.sendServerBusy(p.remoteAddr, hdr); err != nil { + if err := s.sendConnectionRefused(p.remoteAddr, hdr); err != nil { s.logger.Debugf("Error rejecting connection: %s", err) } }() @@ -566,9 +566,9 @@ func (s *baseServer) maybeSendInvalidToken(p *receivedPacket, hdr *wire.Header) return s.sendError(p.remoteAddr, hdr, sealer, qerr.InvalidToken) } -func (s *baseServer) sendServerBusy(remoteAddr net.Addr, hdr *wire.Header) error { +func (s *baseServer) sendConnectionRefused(remoteAddr net.Addr, hdr *wire.Header) error { sealer, _ := handshake.NewInitialAEAD(hdr.DestConnectionID, protocol.PerspectiveServer) - return s.sendError(remoteAddr, hdr, sealer, qerr.ServerBusy) + return s.sendError(remoteAddr, hdr, sealer, qerr.ConnectionRefused) } // sendError sends the error as a response to the packet received with header hdr