dap: Wrap Child directly in a mutex rather than through Option<_> (#40192)

Release Notes:

- N/A
This commit is contained in:
Jakub Konka 2025-10-15 17:14:04 +02:00 committed by GitHub
parent 85c2dc909d
commit d6c9d00a4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -649,7 +649,7 @@ impl Drop for TcpTransport {
}
pub struct StdioTransport {
process: Mutex<Option<Child>>,
process: Mutex<Child>,
_stderr_task: Option<Task<()>>,
}
@ -684,7 +684,7 @@ impl StdioTransport {
))
});
let process = Mutex::new(Some(process));
let process = Mutex::new(process);
Ok(Self {
process,
@ -699,9 +699,7 @@ impl Transport for StdioTransport {
}
fn kill(&mut self) {
if let Some(process) = &mut *self.process.lock() {
process.kill();
}
self.process.lock().kill();
}
fn connect(
@ -713,8 +711,7 @@ impl Transport for StdioTransport {
)>,
> {
let result = util::maybe!({
let mut guard = self.process.lock();
let process = guard.as_mut().context("oops")?;
let mut process = self.process.lock();
Ok((
Box::new(process.stdin.take().context("Cannot reconnect")?) as _,
Box::new(process.stdout.take().context("Cannot reconnect")?) as _,
@ -730,9 +727,7 @@ impl Transport for StdioTransport {
impl Drop for StdioTransport {
fn drop(&mut self) {
if let Some(process) = &mut *self.process.lock() {
process.kill();
}
self.process.lock().kill();
}
}