rename the duration that we keep old connection ID mappings alive

This commit is contained in:
Marten Seemann
2018-11-13 14:17:40 +07:00
parent a3831b2134
commit 1dd0b9a635
3 changed files with 11 additions and 11 deletions

View File

@@ -94,9 +94,9 @@ const DefaultIdleTimeout = 30 * time.Second
// DefaultHandshakeTimeout is the default timeout for a connection until the crypto handshake succeeds. // DefaultHandshakeTimeout is the default timeout for a connection until the crypto handshake succeeds.
const DefaultHandshakeTimeout = 10 * time.Second const DefaultHandshakeTimeout = 10 * time.Second
// ClosedSessionDeleteTimeout the server ignores packets arriving on a connection that is already closed // RetiredConnectionIDDeleteTimeout is the time we keep closed sessions around in order to retransmit the CONNECTION_CLOSE.
// after this time all information about the old connection will be deleted // after this time all information about the old connection will be deleted
const ClosedSessionDeleteTimeout = time.Minute const RetiredConnectionIDDeleteTimeout = time.Minute
// MinStreamFrameSize is the minimum size that has to be left in a packet, so that we add another STREAM frame. // MinStreamFrameSize is the minimum size that has to be left in a packet, so that we add another STREAM frame.
// This avoids splitting up STREAM frames into small pieces, which has 2 advantages: // This avoids splitting up STREAM frames into small pieces, which has 2 advantages:

View File

@@ -26,7 +26,7 @@ type packetHandlerMap struct {
server unknownPacketHandler server unknownPacketHandler
closed bool closed bool
deleteClosedSessionsAfter time.Duration deleteRetiredSessionsAfter time.Duration
logger utils.Logger logger utils.Logger
} }
@@ -38,7 +38,7 @@ func newPacketHandlerMap(conn net.PacketConn, connIDLen int, logger utils.Logger
conn: conn, conn: conn,
connIDLen: connIDLen, connIDLen: connIDLen,
handlers: make(map[string]packetHandler), handlers: make(map[string]packetHandler),
deleteClosedSessionsAfter: protocol.ClosedSessionDeleteTimeout, deleteRetiredSessionsAfter: protocol.RetiredConnectionIDDeleteTimeout,
logger: logger, logger: logger,
} }
go m.listen() go m.listen()
@@ -56,7 +56,7 @@ func (h *packetHandlerMap) Retire(id protocol.ConnectionID) {
} }
func (h *packetHandlerMap) retireByConnectionIDAsString(id string) { func (h *packetHandlerMap) retireByConnectionIDAsString(id string) {
time.AfterFunc(h.deleteClosedSessionsAfter, func() { time.AfterFunc(h.deleteRetiredSessionsAfter, func() {
h.mutex.Lock() h.mutex.Lock()
delete(h.handlers, id) delete(h.handlers, id)
h.mutex.Unlock() h.mutex.Unlock()

View File

@@ -89,7 +89,7 @@ var _ = Describe("Packet Handler Map", func() {
}) })
It("deletes closed session entries after a wait time", func() { It("deletes closed session entries after a wait time", func() {
handler.deleteClosedSessionsAfter = 10 * time.Millisecond handler.deleteRetiredSessionsAfter = 10 * time.Millisecond
connID := protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8} connID := protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8}
handler.Add(connID, NewMockPacketHandler(mockCtrl)) handler.Add(connID, NewMockPacketHandler(mockCtrl))
handler.Retire(connID) handler.Retire(connID)
@@ -98,7 +98,7 @@ var _ = Describe("Packet Handler Map", func() {
}) })
It("passes packets arriving late for closed sessions to that session", func() { It("passes packets arriving late for closed sessions to that session", func() {
handler.deleteClosedSessionsAfter = time.Hour handler.deleteRetiredSessionsAfter = time.Hour
connID := protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8} connID := protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8}
packetHandler := NewMockPacketHandler(mockCtrl) packetHandler := NewMockPacketHandler(mockCtrl)
packetHandler.EXPECT().GetVersion().Return(protocol.VersionWhatever) packetHandler.EXPECT().GetVersion().Return(protocol.VersionWhatever)