Skip to content

Commit fb90e4c

Browse files
committed
Restore DISCONNECTED state in oneshot::Packet::send
Closes rust-lang#32114
1 parent 5045d4e commit fb90e4c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/libstd/sync/mpsc/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,13 @@ mod tests {
19401940
// wait for the child thread to exit before we exit
19411941
rx2.recv().unwrap();
19421942
}
1943+
1944+
#[test]
1945+
fn issue_32114() {
1946+
let (tx, _) = channel();
1947+
let _ = tx.send(123);
1948+
assert_eq!(tx.send(123), Err(SendError(123)));
1949+
}
19431950
}
19441951

19451952
#[cfg(all(test, not(target_os = "emscripten")))]

src/libstd/sync/mpsc/oneshot.rs

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ impl<T> Packet<T> {
113113
// Couldn't send the data, the port hung up first. Return the data
114114
// back up the stack.
115115
DISCONNECTED => {
116+
self.state.swap(DISCONNECTED, Ordering::SeqCst);
117+
self.upgrade = NothingSent;
116118
Err(self.data.take().unwrap())
117119
}
118120

0 commit comments

Comments
 (0)