summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBigo <bigo@crisidev.org>2020-05-02 11:21:19 +0200
committerWez Furlong <wez@wezfurlong.org>2020-05-02 09:21:40 -0700
commitb77eef16d85f972f524b8f48c3f741a45f739159 (patch)
tree866426164b8fe0bf8f40a174667b97f043bcd942
parentcdf9ee98287298e4620391d5bbb9cd1120a96da8 (diff)
downloadssh2-rs-b77eef16d85f972f524b8f48c3f741a45f739159.zip
Remove assertion during SFTP Drop to avoid an uncatchable panic. Closes: #180
Signed-off-by: Bigo <bigo@crisidev.org>
-rw-r--r--src/sftp.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/sftp.rs b/src/sftp.rs
index 491b447..e35b516 100644
--- a/src/sftp.rs
+++ b/src/sftp.rs
@@ -432,7 +432,9 @@ impl Drop for Sftp {
let sess = inner.sess.lock();
let was_blocking = sess.is_blocking();
sess.set_blocking(true);
- assert_eq!(unsafe { raw::libssh2_sftp_shutdown(inner.raw) }, 0);
+ // The shutdown statement can go wrong and return an error code, but we are too late
+ // in the execution to recover it.
+ let _shutdown_result = unsafe { raw::libssh2_sftp_shutdown(inner.raw) };
sess.set_blocking(was_blocking);
}
}
@@ -446,7 +448,7 @@ impl File {
unsafe fn from_raw(sftp: &Sftp, raw: *mut raw::LIBSSH2_SFTP_HANDLE) -> File {
File {
inner: Some(FileInner {
- raw: raw,
+ raw,
sftp: Arc::clone(
sftp.inner
.as_ref()
@@ -642,7 +644,9 @@ impl Drop for File {
let sess_inner = file_inner.sftp.sess.lock();
let was_blocking = sess_inner.is_blocking();
sess_inner.set_blocking(true);
- assert_eq!(unsafe { raw::libssh2_sftp_close_handle(file_inner.raw) }, 0);
+ // The close statement can go wrong and return an error code, but we are too late
+ // in the execution to recover it.
+ let _close_handle_result = unsafe { raw::libssh2_sftp_close_handle(file_inner.raw) };
sess_inner.set_blocking(was_blocking);
}
}