device: separate timersInit from timersStart
timersInit sets up the timers. It need only be done once per peer. timersStart does the work to prepare the timers for a newly running peer. It needs to be done every time a peer starts. Separate the two and call them in the appropriate places. This prevents data races on the peer's timers fields when starting and stopping peers. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
@@ -107,6 +107,7 @@ func (device *Device) NewPeer(pk NoisePublicKey) (*Peer, error) {
|
||||
device.peers.empty.Set(false)
|
||||
|
||||
// start peer
|
||||
peer.timersInit()
|
||||
if peer.device.isUp() {
|
||||
peer.Start()
|
||||
}
|
||||
@@ -183,7 +184,7 @@ func (peer *Peer) Start() {
|
||||
}
|
||||
peer.device.queue.encryption.wg.Add(1) // keep encryption queue open for our writes
|
||||
|
||||
peer.timersInit()
|
||||
peer.timersStart()
|
||||
|
||||
go peer.RoutineSequentialSender()
|
||||
go peer.RoutineSequentialReceiver()
|
||||
|
||||
Reference in New Issue
Block a user