2
0
mirror of synced 2025-02-24 14:48:27 +00:00

Fix crash causing deadlock in connection writer when no messages have been posted yet

This commit is contained in:
Matt Joiner 2016-06-27 15:45:15 +10:00
parent 364f617ade
commit 874bba43f8

View File

@ -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()