device: set peer to expire unconditionally (#73)
e3ac4a0afb4e introduced a lightweight API that can be used instead of UAPI to reconfigure peers. Peer state created via the new PeerLookupFunc is not set to expire until the handshake succeeds, making device leak two goroutines and a set of buffers for each failed handshake. This change arms the expiry timer before the handshake gets to proceed. Updates tailscale/tailscale#20183 Change-Id: Ibc0abb6eec97aca0a10f50515dea9e0d6a6a6964 Signed-off-by: Alex Valiushko <alexvaliushko@tailscale.com>
This commit is contained in:
parent
cd7ac13b86
commit
35a60acb84
1 changed files with 8 additions and 0 deletions
|
|
@ -254,6 +254,14 @@ func (peer *Peer) Start() {
|
|||
go peer.RoutineSequentialReceiver(batchSize)
|
||||
|
||||
peer.isRunning.Store(true)
|
||||
|
||||
// A lazily-created peer that never completes a handshake otherwise never
|
||||
// arms its reaping timer. Arm it here, while running under state.Lock, so
|
||||
// it's reclaimed after RejectAfterTime*3 of no session and is guaranteed to
|
||||
// be torn down by a matching Stop. A completed handshake re-Mods it.
|
||||
if peer.deleteOnIdle {
|
||||
peer.timers.zeroKeyMaterial.Mod(RejectAfterTime * 3)
|
||||
}
|
||||
}
|
||||
|
||||
func (peer *Peer) ZeroAndFlushAll() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue