diff --git a/substrate/core/network-libp2p/src/custom_proto/upgrade.rs b/substrate/core/network-libp2p/src/custom_proto/upgrade.rs index 4bc52c21300230da40c5ad55236de96588ebedb3..992989b3f32ee23ccdd5f95c2b16350c6a1f9c93 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.