Skip to content

Commit

Permalink
Restore DISCONNECTED state in oneshot::Packet::send
Browse files Browse the repository at this point in the history
Closes #32114
  • Loading branch information
apasel422 committed Oct 5, 2016
1 parent 5045d4e commit fb90e4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/libstd/sync/mpsc/mod.rs
Expand Up @@ -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")))]
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/sync/mpsc/oneshot.rs
Expand Up @@ -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())
}

Expand Down

0 comments on commit fb90e4c

Please sign in to comment.