Fix panic when connection is reset immediately after establishing. default tip
authorStiletto <blasux@blasux.ru>
Wed, 19 Mar 2014 14:13:02 +0400
changeset 185 ba8a4ae40e13
parent 184 ce49140fe60b
Fix panic when connection is reset immediately after establishing.
xmpp/xmpp.go
--- a/xmpp/xmpp.go	Thu Feb 20 15:55:19 2014 -0700
+++ b/xmpp/xmpp.go	Wed Mar 19 14:13:02 2014 +0400
@@ -261,7 +261,11 @@
 	cl.setStatus(StatusShutdown)
 
 	// Shuts down the senders:
-	cl.shutdownOnce.Do(func() { close(cl.Send) })
+	cl.shutdownOnce.Do(func() {
+		if cl.Send != nil {
+			close(cl.Send)
+		}
+	})
 }
 
 // If there's a buffered error in the channel, return it. Otherwise,