Fix bug that caused crash in go 1.1

This commit is contained in:
Derek Collison
2013-05-31 08:12:51 -07:00
parent 2bdb873426
commit 0af6ae2455

View File

@@ -73,9 +73,16 @@ func clientConnStr(conn net.Conn) interface{} {
}
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
conn := c.conn
if conn == nil {
return
}
b := make([]byte, defaultBufSize)
for {
n, err := c.conn.Read(b)
n, err := conn.Read(b)
if err != nil {
c.closeConnection()
return