mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 19:49:57 +00:00
TUN-8775: Make sure the session Close can only be called once
The previous capture of the sync.OnceValue was re-initialized for each call to `Close`. This needed to be initialized during the creation of the session to ensure that the sync.OnceValue reference was held for the session's lifetime. Closes TUN-8775
This commit is contained in:
@@ -255,11 +255,16 @@ func TestSessionClose_Multiple(t *testing.T) {
|
||||
if !origin.closed.Load() {
|
||||
t.Fatal("origin wasn't closed")
|
||||
}
|
||||
// Reset the closed status to make sure it isn't closed again
|
||||
origin.closed.Store(false)
|
||||
// subsequent closes shouldn't call close again or cause any errors
|
||||
err = session.Close()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if origin.closed.Load() {
|
||||
t.Fatal("origin was incorrectly closed twice")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionServe_IdleTimeout(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user