From: Matt Joiner Date: Mon, 27 Jun 2016 05:45:15 +0000 (+1000) Subject: Fix crash causing deadlock in connection writer when no messages have been posted yet X-Git-Tag: v1.0.0~672 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=874bba43f8e946efa5a2737c139f3d8dcd3f8d9d;p=btrtrc.git Fix crash causing deadlock in connection writer when no messages have been posted yet --- diff --git a/connection.go b/connection.go index 366adbe4..3f0c4756 100644 --- a/connection.go +++ b/connection.go @@ -408,7 +408,7 @@ func (cn *connection) writer(keepAliveTimeout time.Duration) { keepAliveTimer := time.NewTimer(keepAliveTimeout) for { cn.mu().Lock() - for cn.outgoingUnbufferedMessages.Len() != 0 { + for cn.outgoingUnbufferedMessages != nil && cn.outgoingUnbufferedMessages.Len() != 0 { msg := cn.outgoingUnbufferedMessages.Remove(cn.outgoingUnbufferedMessages.Front()).(pp.Message) cn.mu().Unlock() b, err := msg.MarshalBinary()