ssh remoting: Fix SSH connection not being closed (#18329)
This fixes the `SshSession` being leaked. There were two leaks: 1. `Arc<SshSession>` itself got leaked into the `SettingsObserver` that lives as long as the application. Fixed with a weak reference. 2. The two tasks spawned by an `SshSession` had a circular dependency and didn't exit while the other one was running. Fixed by fixing (1) and then attaching one of the tasks to the `SshSession`, which means it gets dropped with the session itself, which leads the other task to error and exit. Co-authored-by: Bennet <bennet@zed.dev> Release Notes: - N/A --------- Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
parent
623a6eca75
commit
9d197ddc99
5 changed files with 53 additions and 15 deletions
|
@ -10,11 +10,29 @@ use proto::{
|
|||
error::ErrorExt as _, AnyTypedEnvelope, EntityMessage, Envelope, EnvelopedMessage,
|
||||
RequestMessage, TypedEnvelope,
|
||||
};
|
||||
use std::{any::TypeId, sync::Arc};
|
||||
use std::{
|
||||
any::TypeId,
|
||||
sync::{Arc, Weak},
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AnyProtoClient(Arc<dyn ProtoClient>);
|
||||
|
||||
impl AnyProtoClient {
|
||||
pub fn downgrade(&self) -> AnyWeakProtoClient {
|
||||
AnyWeakProtoClient(Arc::downgrade(&self.0))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AnyWeakProtoClient(Weak<dyn ProtoClient>);
|
||||
|
||||
impl AnyWeakProtoClient {
|
||||
pub fn upgrade(&self) -> Option<AnyProtoClient> {
|
||||
self.0.upgrade().map(AnyProtoClient)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ProtoClient: Send + Sync {
|
||||
fn request(
|
||||
&self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue