Skip to content
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

Fix SendDatagram #4436

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions connection.go
Expand Up @@ -2358,9 +2358,10 @@ func (s *connection) SendDatagram(p []byte) error {
}

f := &wire.DatagramFrame{DataLenPresent: true}
if protocol.ByteCount(len(p)) > f.MaxDataLen(s.peerParams.MaxDatagramFrameSize, s.version) {
maxDataLen := f.MaxDataLen(s.peerParams.MaxDatagramFrameSize, s.version)
if protocol.ByteCount(len(p)) > maxDataLen {
return &DatagramTooLargeError{
PeerMaxDatagramFrameSize: int64(s.peerParams.MaxDatagramFrameSize),
PeerMaxDatagramFrameSize: int64(maxDataLen),
}
}
f.Data = make([]byte, len(p))
Expand Down
10 changes: 0 additions & 10 deletions errors.go
Expand Up @@ -49,11 +49,6 @@ type StreamError struct {
Remote bool
}

func (e *StreamError) Is(target error) bool {
_, ok := target.(*StreamError)
return ok
}

func (e *StreamError) Error() string {
pers := "local"
if e.Remote {
Expand All @@ -67,9 +62,4 @@ type DatagramTooLargeError struct {
PeerMaxDatagramFrameSize int64
}

func (e *DatagramTooLargeError) Is(target error) bool {
_, ok := target.(*DatagramTooLargeError)
return ok
}

func (e *DatagramTooLargeError) Error() string { return "DATAGRAM frame too large" }
5 changes: 5 additions & 0 deletions integrationtests/self/cancelation_test.go
Expand Up @@ -246,6 +246,7 @@ var _ = Describe("Stream Cancellations", func() {
Expect(err).To(MatchError(&quic.StreamError{
StreamID: str.StreamID(),
ErrorCode: quic.StreamErrorCode(str.StreamID()),
Remote: true,
}))
return
}
Expand Down Expand Up @@ -356,6 +357,7 @@ var _ = Describe("Stream Cancellations", func() {
Expect(err).To(MatchError(&quic.StreamError{
StreamID: str.StreamID(),
ErrorCode: quic.StreamErrorCode(str.StreamID()),
Remote: true,
}))
return
}
Expand Down Expand Up @@ -396,6 +398,7 @@ var _ = Describe("Stream Cancellations", func() {
Expect(err).To(MatchError(&quic.StreamError{
StreamID: str.StreamID(),
ErrorCode: quic.StreamErrorCode(str.StreamID()),
Remote: true,
}))
return
}
Expand Down Expand Up @@ -441,6 +444,7 @@ var _ = Describe("Stream Cancellations", func() {
Expect(err).To(MatchError(&quic.StreamError{
StreamID: str.StreamID(),
ErrorCode: quic.StreamErrorCode(str.StreamID()),
Remote: true,
}))
return
}
Expand Down Expand Up @@ -486,6 +490,7 @@ var _ = Describe("Stream Cancellations", func() {
Expect(err).To(MatchError(&quic.StreamError{
StreamID: str.StreamID(),
ErrorCode: quic.StreamErrorCode(str.StreamID()),
Remote: true,
}))
return
}
Expand Down