diff options
| author | Alex Chan <alexc@tailscale.com> | 2025-11-21 16:40:37 +0000 |
|---|---|---|
| committer | Alex Chan <alex@alexwlchan.net> | 2025-11-21 17:20:28 +0000 |
| commit | ce95bc77fb0c323e2e4335665bc75d93bf1e7cfc (patch) | |
| tree | fa481e5a551f75e4f38eb3d137e04cf90c4a4195 | |
| parent | c679aaba32c27681845466df9e6df69fe0704b95 (diff) | |
| download | tailscale-ce95bc77fb0c323e2e4335665bc75d93bf1e7cfc.tar.xz tailscale-ce95bc77fb0c323e2e4335665bc75d93bf1e7cfc.zip | |
tka: don't panic if no clock set in tka.Mem
This is causing confusing panics in tailscale/corp#34485. We'll keep
using the tka.ChonkMem constructor as much as we can, but don't panic
if you create a tka.Mem directly -- we know what the sensible thing is.
Updates #cleanup
Signed-off-by: Alex Chan <alexc@tailscale.com>
Change-Id: I49309f5f403fc26ce4f9a6cf0edc8eddf6a6f3a4
| -rw-r--r-- | tka/tailchonk.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tka/tailchonk.go b/tka/tailchonk.go index a55033bcd..13bdf6aac 100644 --- a/tka/tailchonk.go +++ b/tka/tailchonk.go @@ -193,7 +193,7 @@ updateLoop: for _, aum := range updates { aumHash := aum.Hash() c.aums[aumHash] = aum - c.commitTimes[aumHash] = c.clock.Now() + c.commitTimes[aumHash] = c.now() parent, ok := aum.Parent() if ok { @@ -209,6 +209,16 @@ updateLoop: return nil } +// now returns the current time, optionally using the overridden +// clock if set. +func (c *Mem) now() time.Time { + if c.clock == nil { + return time.Now() + } else { + return c.clock.Now() + } +} + // RemoveAll permanently and completely clears the TKA state. func (c *Mem) RemoveAll() error { c.mu.Lock() |
