rename ResetStreamFrame.ByteOffset to FinalSize

This commit is contained in:
Marten Seemann 2020-07-02 16:20:44 +07:00
parent cc340b2887
commit 865332015c
13 changed files with 50 additions and 50 deletions

View file

@ -121,12 +121,12 @@ func getFrames() []wire.Frame {
&wire.ResetStreamFrame{
StreamID: protocol.StreamID(getRandomNumber()),
ErrorCode: quic.ErrorCode(getRandomNumber()),
ByteOffset: protocol.ByteCount(getRandomNumber()),
FinalSize: protocol.ByteCount(getRandomNumber()),
},
&wire.ResetStreamFrame{ // at maximum offset
StreamID: protocol.StreamID(getRandomNumber()),
ErrorCode: quic.ErrorCode(getRandomNumber()),
ByteOffset: protocol.MaxByteCount,
FinalSize: protocol.MaxByteCount,
},
&wire.StopSendingFrame{
StreamID: protocol.StreamID(getRandomNumber()),

View file

@ -83,7 +83,7 @@ var _ = Describe("Frame parsing", func() {
It("unpacks RESET_STREAM frames", func() {
f := &ResetStreamFrame{
StreamID: 0xdeadbeef,
ByteOffset: 0xdecafbad1234,
FinalSize: 0xdecafbad1234,
ErrorCode: 0x1337,
}
err := f.Write(buf, versionIETFFrames)

View file

@ -24,7 +24,7 @@ func LogFrame(logger utils.Logger, frame Frame, sent bool) {
case *StreamFrame:
logger.Debugf("\t%s &wire.StreamFrame{StreamID: %d, FinBit: %t, Offset: %d, Data length: %d, Offset + Data length: %d}", dir, f.StreamID, f.FinBit, f.Offset, f.DataLen(), f.Offset+f.DataLen())
case *ResetStreamFrame:
logger.Debugf("\t%s &wire.ResetStreamFrame{StreamID: %d, ErrorCode: %#x, ByteOffset: %d}", dir, f.StreamID, f.ErrorCode, f.ByteOffset)
logger.Debugf("\t%s &wire.ResetStreamFrame{StreamID: %d, ErrorCode: %#x, FinalSize: %d}", dir, f.StreamID, f.ErrorCode, f.FinalSize)
case *AckFrame:
if len(f.AckRanges) > 1 {
ackRanges := make([]string, len(f.AckRanges))

View file

@ -38,12 +38,12 @@ var _ = Describe("Frame logging", func() {
It("logs sent frames", func() {
LogFrame(logger, &ResetStreamFrame{}, true)
Expect(buf.String()).To(ContainSubstring("\t-> &wire.ResetStreamFrame{StreamID: 0, ErrorCode: 0x0, ByteOffset: 0}\n"))
Expect(buf.String()).To(ContainSubstring("\t-> &wire.ResetStreamFrame{StreamID: 0, ErrorCode: 0x0, FinalSize: 0}\n"))
})
It("logs received frames", func() {
LogFrame(logger, &ResetStreamFrame{}, false)
Expect(buf.String()).To(ContainSubstring("\t<- &wire.ResetStreamFrame{StreamID: 0, ErrorCode: 0x0, ByteOffset: 0}\n"))
Expect(buf.String()).To(ContainSubstring("\t<- &wire.ResetStreamFrame{StreamID: 0, ErrorCode: 0x0, FinalSize: 0}\n"))
})
It("logs CRYPTO frames", func() {

View file

@ -11,7 +11,7 @@ import (
type ResetStreamFrame struct {
StreamID protocol.StreamID
ErrorCode protocol.ApplicationErrorCode
ByteOffset protocol.ByteCount
FinalSize protocol.ByteCount
}
func parseResetStreamFrame(r *bytes.Reader, _ protocol.VersionNumber) (*ResetStreamFrame, error) {
@ -39,7 +39,7 @@ func parseResetStreamFrame(r *bytes.Reader, _ protocol.VersionNumber) (*ResetStr
return &ResetStreamFrame{
StreamID: streamID,
ErrorCode: protocol.ApplicationErrorCode(errorCode),
ByteOffset: byteOffset,
FinalSize: byteOffset,
}, nil
}
@ -47,11 +47,11 @@ func (f *ResetStreamFrame) Write(b *bytes.Buffer, _ protocol.VersionNumber) erro
b.WriteByte(0x4)
utils.WriteVarInt(b, uint64(f.StreamID))
utils.WriteVarInt(b, uint64(f.ErrorCode))
utils.WriteVarInt(b, uint64(f.ByteOffset))
utils.WriteVarInt(b, uint64(f.FinalSize))
return nil
}
// Length of a written frame
func (f *ResetStreamFrame) Length(version protocol.VersionNumber) protocol.ByteCount {
return 1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.ErrorCode)) + utils.VarIntLen(uint64(f.ByteOffset))
return 1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.ErrorCode)) + utils.VarIntLen(uint64(f.FinalSize))
}

View file

@ -20,7 +20,7 @@ var _ = Describe("RESET_STREAM frame", func() {
frame, err := parseResetStreamFrame(b, versionIETFFrames)
Expect(err).ToNot(HaveOccurred())
Expect(frame.StreamID).To(Equal(protocol.StreamID(0xdeadbeef)))
Expect(frame.ByteOffset).To(Equal(protocol.ByteCount(0x987654321)))
Expect(frame.FinalSize).To(Equal(protocol.ByteCount(0x987654321)))
Expect(frame.ErrorCode).To(Equal(protocol.ApplicationErrorCode(0x1337)))
})
@ -42,7 +42,7 @@ var _ = Describe("RESET_STREAM frame", func() {
It("writes a sample frame", func() {
frame := ResetStreamFrame{
StreamID: 0x1337,
ByteOffset: 0x11223344decafbad,
FinalSize: 0x11223344decafbad,
ErrorCode: 0xcafe,
}
b := &bytes.Buffer{}
@ -58,7 +58,7 @@ var _ = Describe("RESET_STREAM frame", func() {
It("has the correct min length", func() {
rst := ResetStreamFrame{
StreamID: 0x1337,
ByteOffset: 0x1234567,
FinalSize: 0x1234567,
ErrorCode: 0xde,
}
expectedLen := 1 + utils.VarIntLen(0x1337) + utils.VarIntLen(0x1234567) + 2

View file

@ -142,7 +142,7 @@ func marshalResetStreamFrame(enc *gojay.Encoder, f *wire.ResetStreamFrame) {
enc.StringKey("frame_type", "reset_stream")
enc.Int64Key("stream_id", int64(f.StreamID))
enc.Int64Key("error_code", int64(f.ErrorCode))
enc.Int64Key("final_size", int64(f.ByteOffset))
enc.Int64Key("final_size", int64(f.FinalSize))
}
func marshalStopSendingFrame(enc *gojay.Encoder, f *wire.StopSendingFrame) {

View file

@ -85,7 +85,7 @@ var _ = Describe("Frames", func() {
check(
&wire.ResetStreamFrame{
StreamID: 987,
ByteOffset: 1234,
FinalSize: 1234,
ErrorCode: 42,
},
map[string]interface{}{

View file

@ -268,11 +268,11 @@ func (s *receiveStream) handleResetStreamFrameImpl(frame *wire.ResetStreamFrame)
if s.closedForShutdown {
return false, nil
}
if err := s.flowController.UpdateHighestReceived(frame.ByteOffset, true); err != nil {
if err := s.flowController.UpdateHighestReceived(frame.FinalSize, true); err != nil {
return false, err
}
newlyRcvdFinalOffset := s.finalOffset == protocol.MaxByteCount
s.finalOffset = frame.ByteOffset
s.finalOffset = frame.FinalSize
// ignore duplicate RESET_STREAM frames for this stream (after checking their final offset)
if s.resetRemotely {

View file

@ -508,7 +508,7 @@ var _ = Describe("Receive Stream", func() {
mockSender.EXPECT().onStreamCompleted(streamID)
Expect(str.handleResetStreamFrame(&wire.ResetStreamFrame{
StreamID: streamID,
ByteOffset: 42,
FinalSize: 42,
})).To(Succeed())
str.CancelRead(1234)
})
@ -562,7 +562,7 @@ var _ = Describe("Receive Stream", func() {
Context("receiving RESET_STREAM frames", func() {
rst := &wire.ResetStreamFrame{
StreamID: streamID,
ByteOffset: 42,
FinalSize: 42,
ErrorCode: 1234,
}
@ -624,7 +624,7 @@ var _ = Describe("Receive Stream", func() {
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true).Times(2)
Expect(str.handleStreamFrame(&wire.StreamFrame{
StreamID: streamID,
Offset: rst.ByteOffset,
Offset: rst.FinalSize,
FinBit: true,
})).To(Succeed())
Expect(str.handleResetStreamFrame(rst)).To(Succeed())

View file

@ -417,7 +417,7 @@ func (s *sendStream) cancelWriteImpl(errorCode protocol.ApplicationErrorCode, wr
s.signalWrite()
s.sender.queueControlFrame(&wire.ResetStreamFrame{
StreamID: s.streamID,
ByteOffset: s.writeOffset,
FinalSize: s.writeOffset,
ErrorCode: errorCode,
})
if newlyCompleted {

View file

@ -686,7 +686,7 @@ var _ = Describe("Send Stream", func() {
gomock.InOrder(
mockSender.EXPECT().queueControlFrame(&wire.ResetStreamFrame{
StreamID: streamID,
ByteOffset: 1234,
FinalSize: 1234,
ErrorCode: 9876,
}),
mockSender.EXPECT().onStreamCompleted(streamID),

View file

@ -171,7 +171,7 @@ var _ = Describe("Session", func() {
f := &wire.ResetStreamFrame{
StreamID: 555,
ErrorCode: 42,
ByteOffset: 0x1337,
FinalSize: 0x1337,
}
str := NewMockReceiveStreamI(mockCtrl)
streamManager.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(555)).Return(str, nil)
@ -183,7 +183,7 @@ var _ = Describe("Session", func() {
It("returns errors", func() {
f := &wire.ResetStreamFrame{
StreamID: 7,
ByteOffset: 0x1337,
FinalSize: 0x1337,
}
testErr := errors.New("flow control violation")
str := NewMockReceiveStreamI(mockCtrl)