about summary refs log tree commit diff
path: root/src/libstd/sync/mpsc
diff options
context:
space:
mode:
authorAndrew Paseltiner <apaseltiner@gmail.com>2016-10-01 08:39:11 -0400
committerAndrew Paseltiner <apaseltiner@gmail.com>2016-10-05 17:14:06 -0400
commitfb90e4c7b69dec797d036dc0aac802d9b2a18198 (patch)
tree05795eb9dda9c1c40767986a436eff6cc250d2c5 /src/libstd/sync/mpsc
parent5045d4e39621b265eca947277f07e23f62608ad0 (diff)
downloadrust-fb90e4c7b69dec797d036dc0aac802d9b2a18198.tar.gz
rust-fb90e4c7b69dec797d036dc0aac802d9b2a18198.zip
Restore `DISCONNECTED` state in `oneshot::Packet::send`
Closes #32114
Diffstat (limited to 'src/libstd/sync/mpsc')
-rw-r--r--src/libstd/sync/mpsc/mod.rs7
-rw-r--r--src/libstd/sync/mpsc/oneshot.rs2
2 files changed, 9 insertions, 0 deletions
diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs
index d9c14ef2f77..6d37f160590 100644
--- a/src/libstd/sync/mpsc/mod.rs
+++ b/src/libstd/sync/mpsc/mod.rs
@@ -1940,6 +1940,13 @@ mod tests {
         // wait for the child thread to exit before we exit
         rx2.recv().unwrap();
     }
+
+    #[test]
+    fn issue_32114() {
+        let (tx, _) = channel();
+        let _ = tx.send(123);
+        assert_eq!(tx.send(123), Err(SendError(123)));
+    }
 }
 
 #[cfg(all(test, not(target_os = "emscripten")))]
diff --git a/src/libstd/sync/mpsc/oneshot.rs b/src/libstd/sync/mpsc/oneshot.rs
index 7389280b853..767e9f96ac8 100644
--- a/src/libstd/sync/mpsc/oneshot.rs
+++ b/src/libstd/sync/mpsc/oneshot.rs
@@ -113,6 +113,8 @@ impl<T> Packet<T> {
             // Couldn't send the data, the port hung up first. Return the data
             // back up the stack.
             DISCONNECTED => {
+                self.state.swap(DISCONNECTED, Ordering::SeqCst);
+                self.upgrade = NothingSent;
                 Err(self.data.take().unwrap())
             }