Fix data read race

This commit is contained in:
Derek Collison
2013-07-30 18:44:57 -07:00
parent 1faadcd0fa
commit 8026c3e91d

View File

@@ -114,10 +114,14 @@ func (c *client) initClient() {
func (c *client) readLoop() {
// Grab the connection off the client, it will be cleared on a close.
// We check for that after the loop, but want to avoid a nil dereference
c.mu.Lock()
nc := c.nc
c.mu.Unlock()
if nc == nil {
return
}
b := make([]byte, defaultBufSize)
for {