Restore DISCONNECTED state in oneshot::Packet::send

Closes #32114
This commit is contained in:
Andrew Paseltiner 2016-10-01 08:39:11 -04:00
parent 5045d4e396
commit fb90e4c7b6
No known key found for this signature in database
GPG key ID: DA5CDC15F9BEDB2B
2 changed files with 9 additions and 0 deletions

View file

@ -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")))]

View file

@ -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())
}