From f1f32ac6208fc7d25f99f94e7be9b1f51de53aef Mon Sep 17 00:00:00 2001
From: Pierre Krieger <pierre.krieger1708@gmail.com>
Date: Sat, 19 Jan 2019 12:37:07 +0100
Subject: [PATCH] Don't queue messages after shutdown (#1476)

---
 substrate/core/network-libp2p/src/custom_proto/upgrade.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/substrate/core/network-libp2p/src/custom_proto/upgrade.rs b/substrate/core/network-libp2p/src/custom_proto/upgrade.rs
index 4bc52c21300..992989b3f32 100644
--- a/substrate/core/network-libp2p/src/custom_proto/upgrade.rs
+++ b/substrate/core/network-libp2p/src/custom_proto/upgrade.rs
@@ -103,10 +103,15 @@ impl<TSubstream> RegisteredProtocolSubstream<TSubstream> {
 	/// After calling this, the stream is guaranteed to finish soon-ish.
 	pub fn shutdown(&mut self) {
 		self.is_closing = true;
+		self.send_queue.clear();
 	}
 
 	/// Sends a message to the substream.
 	pub fn send_message(&mut self, data: Bytes) {
+		if self.is_closing {
+			return
+		}
+
 		self.send_queue.push_back(data);
 
 		// If the length of the queue goes over a certain arbitrary threshold, we print a warning.
-- 
GitLab