diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-04-20 23:36:04 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-04-20 23:36:04 +0000 |
commit | a020b29fb4332a42c2e96afde5678ad16b3d89e0 (patch) | |
tree | 10417ac8337849960b03dee2c7239cd25f771825 /pkg/tcpip | |
parent | 80bfc9c407f8dec2393b1efbfa85366e5a9b9efe (diff) | |
parent | 782041509f4130e8e795b22379368239d5091c8f (diff) |
Merge release-20200323.0-197-g7820415 (automated)
Diffstat (limited to 'pkg/tcpip')
-rwxr-xr-x | pkg/tcpip/timer.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/pkg/tcpip/timer.go b/pkg/tcpip/timer.go index f5f01f32f..67f66fc72 100755 --- a/pkg/tcpip/timer.go +++ b/pkg/tcpip/timer.go @@ -131,10 +131,14 @@ func (t *CancellableTimer) StopLocked() { func (t *CancellableTimer) Reset(d time.Duration) { // Create a new instance. earlyReturn := false + + // Capture the locker so that updating the timer does not cause a data race + // when a timer fires and tries to obtain the lock (read the timer's locker). + locker := t.locker t.instance = cancellableTimerInstance{ timer: time.AfterFunc(d, func() { - t.locker.Lock() - defer t.locker.Unlock() + locker.Lock() + defer locker.Unlock() if earlyReturn { // If we reach this point, it means that the timer fired while another |