From 03fe6367112572af6fd410b974d7e0f3388c61f0 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Wed, 17 Feb 2021 11:41:08 +0800 Subject: [PATCH] reduce memory footprint of the connIDManager --- conn_id_manager.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conn_id_manager.go b/conn_id_manager.go index 35b04d336d6..99462376ecf 100644 --- a/conn_id_manager.go +++ b/conn_id_manager.go @@ -21,9 +21,9 @@ type connIDManager struct { // We change the connection ID after sending on average // protocol.PacketsPerConnectionID packets. The actual value is randomized // hide the packet loss rate from on-path observers. - packetsSinceLastChange uint64 rand utils.Rand - packetsPerConnectionID uint64 + packetsSinceLastChange uint32 + packetsPerConnectionID uint32 addStatelessResetToken func(protocol.StatelessResetToken) removeStatelessResetToken func(protocol.StatelessResetToken) @@ -148,7 +148,7 @@ func (h *connIDManager) updateConnectionID() { h.activeConnectionID = front.ConnectionID h.activeStatelessResetToken = &front.StatelessResetToken h.packetsSinceLastChange = 0 - h.packetsPerConnectionID = protocol.PacketsPerConnectionID/2 + uint64(h.rand.Int31n(protocol.PacketsPerConnectionID)) + h.packetsPerConnectionID = protocol.PacketsPerConnectionID/2 + uint32(h.rand.Int31n(protocol.PacketsPerConnectionID)) h.addStatelessResetToken(*h.activeStatelessResetToken) }