rename AckHandler package to AckHandlerLegacy

This commit is contained in:
Marten Seemann 2016-06-18 22:32:51 +07:00
parent 288cb9e143
commit eb03ed5334
16 changed files with 42 additions and 42 deletions

View file

@ -1,4 +1,4 @@
package ackhandler
package ackhandlerlegacy
import (
. "github.com/onsi/ginkgo"
@ -9,5 +9,5 @@ import (
func TestCrypto(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "AckHandler Suite")
RunSpecs(t, "AckHandler (Legacy) Suite")
}

View file

@ -1,4 +1,4 @@
package ackhandler
package ackhandlerlegacy
import "github.com/lucas-clemente/quic-go/protocol"

View file

@ -1,4 +1,4 @@
package ackhandler
package ackhandlerlegacy
import (
. "github.com/onsi/ginkgo"

View file

@ -1,4 +1,4 @@
package ackhandler
package ackhandlerlegacy
import (
"time"

View file

@ -1,4 +1,4 @@
package ackhandler
package ackhandlerlegacy
import (
"time"

View file

@ -1,4 +1,4 @@
package ackhandler
package ackhandlerlegacy
import (
"github.com/lucas-clemente/quic-go/frames"

View file

@ -1,4 +1,4 @@
package ackhandler
package ackhandlerlegacy
import (
"errors"

View file

@ -1,4 +1,4 @@
package ackhandler
package ackhandlerlegacy
import (
"time"

View file

@ -1,4 +1,4 @@
package ackhandler
package ackhandlerlegacy
import (
"errors"

View file

@ -1,4 +1,4 @@
package ackhandler
package ackhandlerlegacy
import (
"time"

View file

@ -1,4 +1,4 @@
package ackhandler
package ackhandlerlegacy
import (
"github.com/lucas-clemente/quic-go/frames"

View file

@ -1,4 +1,4 @@
package ackhandler
package ackhandlerlegacy
import (
"github.com/lucas-clemente/quic-go/protocol"

View file

@ -5,7 +5,7 @@ import (
"errors"
"sync/atomic"
"github.com/lucas-clemente/quic-go/ackhandler"
"github.com/lucas-clemente/quic-go/ackhandlerlegacy"
"github.com/lucas-clemente/quic-go/frames"
"github.com/lucas-clemente/quic-go/handshake"
"github.com/lucas-clemente/quic-go/protocol"
@ -24,7 +24,7 @@ type packetPacker struct {
version protocol.VersionNumber
cryptoSetup *handshake.CryptoSetup
sentPacketHandler ackhandler.SentPacketHandler
sentPacketHandler ackhandlerlegacy.SentPacketHandler
connectionParametersManager *handshake.ConnectionParametersManager
streamFrameQueue *streamFrameQueue
@ -34,7 +34,7 @@ type packetPacker struct {
lastPacketNumber protocol.PacketNumber
}
func newPacketPacker(connectionID protocol.ConnectionID, cryptoSetup *handshake.CryptoSetup, sentPacketHandler ackhandler.SentPacketHandler, connectionParametersHandler *handshake.ConnectionParametersManager, blockedManager *blockedManager, streamFrameQueue *streamFrameQueue, version protocol.VersionNumber) *packetPacker {
func newPacketPacker(connectionID protocol.ConnectionID, cryptoSetup *handshake.CryptoSetup, sentPacketHandler ackhandlerlegacy.SentPacketHandler, connectionParametersHandler *handshake.ConnectionParametersManager, blockedManager *blockedManager, streamFrameQueue *streamFrameQueue, version protocol.VersionNumber) *packetPacker {
return &packetPacker{
cryptoSetup: cryptoSetup,
connectionID: connectionID,

View file

@ -4,7 +4,7 @@ import (
"bytes"
"time"
"github.com/lucas-clemente/quic-go/ackhandler"
"github.com/lucas-clemente/quic-go/ackhandlerlegacy"
"github.com/lucas-clemente/quic-go/frames"
"github.com/lucas-clemente/quic-go/handshake"
"github.com/lucas-clemente/quic-go/protocol"
@ -13,10 +13,10 @@ import (
)
type mockSentPacketHandler struct {
retransmissionQueue []*ackhandler.Packet
retransmissionQueue []*ackhandlerlegacy.Packet
}
func (h *mockSentPacketHandler) SentPacket(packet *ackhandler.Packet) error { return nil }
func (h *mockSentPacketHandler) SentPacket(packet *ackhandlerlegacy.Packet) error { return nil }
func (h *mockSentPacketHandler) ReceivedAck(ackFrame *frames.AckFrameLegacy) error { return nil }
func (h *mockSentPacketHandler) BytesInFlight() protocol.ByteCount { return 0 }
func (h *mockSentPacketHandler) GetLargestObserved() protocol.PacketNumber { return 1 }
@ -28,7 +28,7 @@ func (h *mockSentPacketHandler) ProbablyHasPacketForRetransmission() bool {
return len(h.retransmissionQueue) > 0
}
func (h *mockSentPacketHandler) DequeuePacketForRetransmission() *ackhandler.Packet {
func (h *mockSentPacketHandler) DequeuePacketForRetransmission() *ackhandlerlegacy.Packet {
if len(h.retransmissionQueue) > 0 {
packet := h.retransmissionQueue[0]
h.retransmissionQueue = h.retransmissionQueue[1:]
@ -37,7 +37,7 @@ func (h *mockSentPacketHandler) DequeuePacketForRetransmission() *ackhandler.Pac
return nil
}
func newMockSentPacketHandler() ackhandler.SentPacketHandler {
func newMockSentPacketHandler() ackhandlerlegacy.SentPacketHandler {
return &mockSentPacketHandler{}
}

View file

@ -8,7 +8,7 @@ import (
"sync/atomic"
"time"
"github.com/lucas-clemente/quic-go/ackhandler"
"github.com/lucas-clemente/quic-go/ackhandlerlegacy"
"github.com/lucas-clemente/quic-go/flowcontrol"
"github.com/lucas-clemente/quic-go/frames"
"github.com/lucas-clemente/quic-go/handshake"
@ -49,9 +49,9 @@ type Session struct {
openStreamsCount uint32
streamsMutex sync.RWMutex
sentPacketHandler ackhandler.SentPacketHandler
receivedPacketHandler ackhandler.ReceivedPacketHandler
stopWaitingManager ackhandler.StopWaitingManager
sentPacketHandler ackhandlerlegacy.SentPacketHandler
receivedPacketHandler ackhandlerlegacy.ReceivedPacketHandler
stopWaitingManager ackhandlerlegacy.StopWaitingManager
windowUpdateManager *windowUpdateManager
blockedManager *blockedManager
streamFrameQueue *streamFrameQueue
@ -90,7 +90,7 @@ type Session struct {
// newSession makes a new session
func newSession(conn connection, v protocol.VersionNumber, connectionID protocol.ConnectionID, sCfg *handshake.ServerConfig, streamCallback StreamCallback, closeCallback closeCallback) (packetHandler, error) {
stopWaitingManager := ackhandler.NewStopWaitingManager()
stopWaitingManager := ackhandlerlegacy.NewStopWaitingManager()
connectionParametersManager := handshake.NewConnectionParamatersManager()
session := &Session{
@ -100,8 +100,8 @@ func newSession(conn connection, v protocol.VersionNumber, connectionID protocol
streamCallback: streamCallback,
closeCallback: closeCallback,
streams: make(map[protocol.StreamID]*stream),
sentPacketHandler: ackhandler.NewSentPacketHandler(stopWaitingManager),
receivedPacketHandler: ackhandler.NewReceivedPacketHandler(),
sentPacketHandler: ackhandlerlegacy.NewSentPacketHandler(stopWaitingManager),
receivedPacketHandler: ackhandlerlegacy.NewReceivedPacketHandler(),
stopWaitingManager: stopWaitingManager,
flowControlManager: flowcontrol.NewFlowControlManager(connectionParametersManager),
flowController: flowcontrol.NewFlowController(0, connectionParametersManager),
@ -271,7 +271,7 @@ func (s *Session) handleFrames(fs []frames.Frame) error {
if err != nil {
switch err {
case ackhandler.ErrDuplicateOrOutOfOrderAck:
case ackhandlerlegacy.ErrDuplicateOrOutOfOrderAck:
// Can happen e.g. when packets thought missing arrive late
case errRstStreamOnInvalidStream:
// Can happen when RST_STREAMs arrive early or late (?)
@ -536,7 +536,7 @@ func (s *Session) sendPacket() error {
return nil
}
err = s.sentPacketHandler.SentPacket(&ackhandler.Packet{
err = s.sentPacketHandler.SentPacket(&ackhandlerlegacy.Packet{
PacketNumber: packet.number,
Frames: packet.frames,
EntropyBit: packet.entropyBit,

View file

@ -12,7 +12,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/lucas-clemente/quic-go/ackhandler"
"github.com/lucas-clemente/quic-go/ackhandlerlegacy"
"github.com/lucas-clemente/quic-go/crypto"
"github.com/lucas-clemente/quic-go/frames"
"github.com/lucas-clemente/quic-go/handshake"
@ -395,7 +395,7 @@ var _ = Describe("Session", func() {
Context("sending packets", func() {
It("sends ack frames", func() {
packetNumber := protocol.PacketNumber(0x0135)
var entropy ackhandler.EntropyAccumulator
var entropy ackhandlerlegacy.EntropyAccumulator
session.receivedPacketHandler.ReceivedPacket(packetNumber, true)
entropy.Add(packetNumber, true)
err := session.sendPacket()
@ -502,12 +502,12 @@ var _ = Describe("Session", func() {
StreamID: 0x5,
Data: []byte("foobar1234567"),
}
p := ackhandler.Packet{
p := ackhandlerlegacy.Packet{
PacketNumber: 0x1337,
Frames: []frames.Frame{&f},
}
sph := newMockSentPacketHandler()
sph.(*mockSentPacketHandler).retransmissionQueue = []*ackhandler.Packet{&p}
sph.(*mockSentPacketHandler).retransmissionQueue = []*ackhandlerlegacy.Packet{&p}
session.sentPacketHandler = sph
err := session.sendPacket()
@ -525,16 +525,16 @@ var _ = Describe("Session", func() {
StreamID: 0x7,
Data: []byte("loremipsum"),
}
p1 := ackhandler.Packet{
p1 := ackhandlerlegacy.Packet{
PacketNumber: 0x1337,
Frames: []frames.Frame{&f1},
}
p2 := ackhandler.Packet{
p2 := ackhandlerlegacy.Packet{
PacketNumber: 0x1338,
Frames: []frames.Frame{&f2},
}
sph := newMockSentPacketHandler()
sph.(*mockSentPacketHandler).retransmissionQueue = []*ackhandler.Packet{&p1, &p2}
sph.(*mockSentPacketHandler).retransmissionQueue = []*ackhandlerlegacy.Packet{&p1, &p2}
session.sentPacketHandler = sph
err := session.sendPacket()
@ -679,13 +679,13 @@ var _ = Describe("Session", func() {
It("errors when the SentPacketHandler has too many packets tracked", func() {
streamFrame := frames.StreamFrame{StreamID: 5, Data: []byte("foobar")}
for i := uint32(1); i < protocol.MaxTrackedSentPackets+10; i++ {
packet := ackhandler.Packet{PacketNumber: protocol.PacketNumber(i), Frames: []frames.Frame{&streamFrame}, Length: 1}
packet := ackhandlerlegacy.Packet{PacketNumber: protocol.PacketNumber(i), Frames: []frames.Frame{&streamFrame}, Length: 1}
err := session.sentPacketHandler.SentPacket(&packet)
Expect(err).ToNot(HaveOccurred())
}
// now session.sentPacketHandler.CheckForError will return an error
err := session.sendPacket()
Expect(err).To(MatchError(ackhandler.ErrTooManyTrackedSentPackets))
Expect(err).To(MatchError(ackhandlerlegacy.ErrTooManyTrackedSentPackets))
})
It("stores up to MaxSessionUnprocessedPackets packets", func(done Done) {
@ -700,7 +700,7 @@ var _ = Describe("Session", func() {
// We simulate consistently low RTTs, so that the test works faster
n := protocol.PacketNumber(10)
for p := protocol.PacketNumber(1); p < n; p++ {
err := session.sentPacketHandler.SentPacket(&ackhandler.Packet{PacketNumber: p, Length: 1})
err := session.sentPacketHandler.SentPacket(&ackhandlerlegacy.Packet{PacketNumber: p, Length: 1})
Expect(err).NotTo(HaveOccurred())
time.Sleep(time.Microsecond)
err = session.sentPacketHandler.ReceivedAck(&frames.AckFrameLegacy{LargestObserved: p})
@ -709,7 +709,7 @@ var _ = Describe("Session", func() {
// Now, we send a single packet, and expect that it was retransmitted later
go session.run()
Expect(conn.written).To(BeEmpty())
err := session.sentPacketHandler.SentPacket(&ackhandler.Packet{
err := session.sentPacketHandler.SentPacket(&ackhandlerlegacy.Packet{
PacketNumber: n,
Length: 1,
Frames: []frames.Frame{&frames.StreamFrame{
@ -751,7 +751,7 @@ var _ = Describe("Session", func() {
Context("ignoring errors", func() {
It("ignores duplicate acks", func() {
session.sentPacketHandler.SentPacket(&ackhandler.Packet{
session.sentPacketHandler.SentPacket(&ackhandlerlegacy.Packet{
PacketNumber: 1,
Length: 1,
})