diff --git a/src/sync/mpsc/mod.rs b/src/sync/mpsc/mod.rs index dfb44ec7819..e5b4063c245 100644 --- a/src/sync/mpsc/mod.rs +++ b/src/sync/mpsc/mod.rs @@ -413,12 +413,16 @@ impl Sender { None }; - self.maybe_parked = true; *self.sender_task.lock().unwrap() = task; // Send handle over queue let t = self.sender_task.clone(); self.inner.parked_queue.push(t); + + // Check to make sure we weren't closed after we sent our task on the + // queue + let state = decode_state(self.inner.state.load(SeqCst)); + self.maybe_parked = state.is_open; } fn poll_unparked(&mut self) -> Async<()> {