handshake: store key update interval in an atomic (#5234)

* handshake: store key update interval in an atomic

We recently changed the way the key update interval is set in tests to
use an environment variable. This resolved a race condition that existed
in the earlier logic, however, parsing of the environment variable now
shows up in benchmark tests.

Using an atomic variable should have a negligible performance impact.

* use an atomic swap
This commit is contained in:
Marten Seemann
2025-06-21 18:14:07 +08:00
committed by GitHub
parent 4bc9dfca93
commit 92aa7b41d5
3 changed files with 17 additions and 15 deletions

View File

@@ -7,6 +7,7 @@ import (
"time"
"github.com/quic-go/quic-go"
"github.com/quic-go/quic-go/internal/handshake"
"github.com/quic-go/quic-go/internal/protocol"
"github.com/quic-go/quic-go/logging"
@@ -14,7 +15,8 @@ import (
)
func TestKeyUpdates(t *testing.T) {
t.Setenv("QUIC_GO_TEST_KEY_UPDATE_INTERVAL", "1") // update keys as frequently as possible
reset := handshake.SetKeyUpdateInterval(1) // update keys as frequently as possible
t.Cleanup(reset)
var sentHeaders []*logging.ShortHeader
var receivedHeaders []*logging.ShortHeader