Skip to content

Commit 0cf443d

Browse files
committed
Rm API Session::force_terminate and mv its functionality
into `Session::close` Signed-off-by: Jiahao XU <[email protected]>
1 parent 2fbbf8e commit 0cf443d

File tree

4 files changed

+6
-30
lines changed

4 files changed

+6
-30
lines changed

src/native_mux_impl/session.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ impl Session {
8282
self.close_impl().await?;
8383

8484
tempdir.close().map_err(Error::Cleanup)?;
85+
} else {
86+
self.close_impl().await?;
8587
}
8688

8789
Ok(())
@@ -96,17 +98,6 @@ impl Session {
9698
}),
9799
)
98100
}
99-
100-
/// Forced termination, ignores value of `tempdir`
101-
pub(crate) async fn force_terminate(self) -> Result<(), Error> {
102-
if self.tempdir.is_some() {
103-
self.close().await
104-
} else {
105-
self.close_impl().await?;
106-
107-
Ok(())
108-
}
109-
}
110101
}
111102

112103
impl Drop for Session {

src/process_impl/session.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ impl Session {
184184
self.close_impl().await?;
185185

186186
tempdir.close().map_err(Error::Cleanup)?;
187+
} else {
188+
self.close_impl().await?;
187189
}
188190

189191
Ok(())
@@ -194,17 +196,6 @@ impl Session {
194196
(self.ctl.clone(), self.master_log.take())
195197
}
196198

197-
/// Forced termination, ignores value of `tempdir`
198-
pub(crate) async fn force_terminate(self) -> Result<(), Error> {
199-
if self.tempdir.is_some() {
200-
self.close().await
201-
} else {
202-
self.close_impl().await?;
203-
204-
Ok(())
205-
}
206-
}
207-
208199
fn discover_master_error(&self) -> Option<Error> {
209200
let err = match fs::read_to_string(self.master_log.as_ref()?) {
210201
Ok(err) => err,

src/session.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,4 @@ impl Session {
328328
pub fn detach(self) -> (Box<Path>, Option<Box<Path>>) {
329329
delegate!(self.0, imp, { imp.detach() })
330330
}
331-
332-
/// Force terminate the remote connection, even if it is created
333-
/// by [`Session::resume`] or [`Session::resume_mux`].
334-
pub async fn force_terminate(self) -> Result<(), Error> {
335-
delegate!(self.0, imp, { imp.force_terminate().await })
336-
}
337331
}

tests/openssh.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ async fn test_detach_and_resume_process_mux() {
865865
let session2 = Session::resume(ctl1, master_log1);
866866
session2.check().await.unwrap();
867867

868-
session2.force_terminate().await.unwrap();
868+
session2.close().await.unwrap();
869869

870870
// Wait for ssh multiplex master to clean up and exit.
871871
sleep(Duration::from_secs(3)).await;
@@ -910,7 +910,7 @@ async fn test_detach_and_resume_native_mux() {
910910
let session2 = Session::resume_mux(ctl1, master_log1);
911911
session2.check().await.unwrap();
912912

913-
session2.force_terminate().await.unwrap();
913+
session2.close().await.unwrap();
914914

915915
// Wait for ssh multiplex master to clean up and exit.
916916
sleep(Duration::from_secs(3)).await;

0 commit comments

Comments
 (0)