From e0fb49d76792f0f31abfa1fc16bc9ca2fc360242 Mon Sep 17 00:00:00 2001 From: clonejo Date: Wed, 3 Jan 2024 23:29:47 +0100 Subject: [PATCH] Fix abort() getting stuck when being passed a reference - It was possible to pass a reference to data_stream, instead of ownership, which the code intended. - Require 'static, ie. normal references cannot be passed anymore. - Could stop old, buggy code from compiling. --- suppaftp/src/async_ftp/mod.rs | 2 +- suppaftp/src/sync_ftp/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/suppaftp/src/async_ftp/mod.rs b/suppaftp/src/async_ftp/mod.rs index 522fea8..c80dca2 100644 --- a/suppaftp/src/async_ftp/mod.rs +++ b/suppaftp/src/async_ftp/mod.rs @@ -523,7 +523,7 @@ where /// abort the previous FTP service command pub async fn abort(&mut self, data_stream: R) -> FtpResult<()> where - R: Read + std::marker::Unpin, + R: Read + std::marker::Unpin + 'static, { debug!("Aborting active file transfer"); self.perform(Command::Abor).await?; diff --git a/suppaftp/src/sync_ftp/mod.rs b/suppaftp/src/sync_ftp/mod.rs index b006b46..485d0ab 100644 --- a/suppaftp/src/sync_ftp/mod.rs +++ b/suppaftp/src/sync_ftp/mod.rs @@ -522,7 +522,7 @@ where } /// abort the previous FTP service command - pub fn abort(&mut self, data_stream: impl Read) -> FtpResult<()> { + pub fn abort(&mut self, data_stream: impl Read + 'static) -> FtpResult<()> { debug!("Aborting active file transfer"); self.perform(Command::Abor)?; // Drop stream NOTE: must be done first, otherwise server won't return any response