From 1c770bb4319fa048a46008e4797041d4125456ce Mon Sep 17 00:00:00 2001 From: Daniel Cormier Date: Fri, 17 Mar 2017 16:09:22 -0400 Subject: [PATCH] Added missing lock when reading field (was already used when writing field) This avoids a data race found in tests involving disconnecting the client with the `-race` flag. --- loop.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/loop.go b/loop.go index 138c2f9..c2b63c1 100644 --- a/loop.go +++ b/loop.go @@ -74,6 +74,9 @@ func (c *Channel) Id() string { Checks that Channel is still alive */ func (c *Channel) IsAlive() bool { + c.aliveLock.Lock() + defer c.aliveLock.Unlock() + return c.alive }