mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 04:05:31 +02:00
Fix (and test) for a deadlock that can happen while waiting for protocol info (#12633)
# Description The local socket PR introduced a `Waitable` type, which could either hold a value or be waited on until a value is available. Unlike a channel, it would always return that value once set. However, one issue with this design was that there was no way to detect whether a value would ever be written. This splits the writer into a different type `WaitableMut`, so that when it is dropped, waiting threads can fail (because they'll never get a value). # Tests + Formatting A test has been added to `stress_internals` to make sure this fails in the right way. - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib`
This commit is contained in:
@ -11,6 +11,7 @@ use serde_json::{json, Value};
|
||||
struct Options {
|
||||
refuse_local_socket: bool,
|
||||
advertise_local_socket: bool,
|
||||
exit_before_hello: bool,
|
||||
exit_early: bool,
|
||||
wrong_version: bool,
|
||||
local_socket_path: Option<String>,
|
||||
@ -28,6 +29,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
let mut opts = Options {
|
||||
refuse_local_socket: has_env("STRESS_REFUSE_LOCAL_SOCKET"),
|
||||
advertise_local_socket: has_env("STRESS_ADVERTISE_LOCAL_SOCKET"),
|
||||
exit_before_hello: has_env("STRESS_EXIT_BEFORE_HELLO"),
|
||||
exit_early: has_env("STRESS_EXIT_EARLY"),
|
||||
wrong_version: has_env("STRESS_WRONG_VERSION"),
|
||||
local_socket_path: None,
|
||||
@ -75,6 +77,11 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
output.flush()?;
|
||||
}
|
||||
|
||||
// Test exiting without `Hello`
|
||||
if opts.exit_before_hello {
|
||||
std::process::exit(1)
|
||||
}
|
||||
|
||||
// Send `Hello` message
|
||||
write(
|
||||
&mut output,
|
||||
|
Reference in New Issue
Block a user