Make an attempt to only close the send channel if it's still open.
authorChris Jones <chris@cjones.org>
Wed, 16 Oct 2013 20:41:14 -0600
changeset 169 f59b79d032da
parent 168 f4ccc2f29777
child 170 d496de556c9a
Make an attempt to only close the send channel if it's still open.
xmpp/xmpp.go
--- a/xmpp/xmpp.go	Wed Oct 16 20:29:29 2013 -0600
+++ b/xmpp/xmpp.go	Wed Oct 16 20:41:14 2013 -0600
@@ -230,8 +230,13 @@
 func (cl *Client) Close() {
 	// Shuts down the receivers:
 	cl.setStatus(StatusShutdown)
+
 	// Shuts down the senders:
-	close(cl.Send)
+	select {
+	case cl.Send <- &Iq{}:
+		close(cl.Send)
+	default:
+	}
 }
 
 // If there's a buffered error in the channel, return it. Otherwise,