device: fix persistent_keepalive_interval data races

Co-authored-by: David Anderson <danderson@tailscale.com>
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder
2020-12-14 15:28:52 -08:00
committed by Jason A. Donenfeld
parent e1fa1cc556
commit 63066ce406
5 changed files with 22 additions and 9 deletions

View File

@@ -215,7 +215,20 @@ func TestConcurrencySafety(t *testing.T) {
}()
warmup.Wait()
// coming soon: more things here...
// Change persistent_keepalive_interval concurrently with tunnel use.
t.Run("persistentKeepaliveInterval", func(t *testing.T) {
cfg := uapiCfg(
"public_key", "f70dbb6b1b92a1dde1c783b297016af3f572fef13b0abb16a2623d89a58e9725",
"persistent_keepalive_interval", "1",
)
for i := 0; i < 1000; i++ {
cfg.Seek(0, io.SeekStart)
err := pair[0].dev.IpcSetOperation(cfg)
if err != nil {
t.Fatal(err)
}
}
})
close(done)
}