diff options
-rw-r--r-- | src/session.rs | 50 | ||||
-rw-r--r-- | tests/channel.rs | 18 |
2 files changed, 21 insertions, 47 deletions
diff --git a/src/session.rs b/src/session.rs index 1a23f5b..d7f3aaa 100644 --- a/src/session.rs +++ b/src/session.rs @@ -626,7 +626,9 @@ impl Binding for Session { impl Drop for Session { fn drop(&mut self) { - unsafe { assert_eq!(raw::libssh2_session_free(self.raw), 0); } + unsafe { + let _rc = raw::libssh2_session_free(self.raw); + } } } @@ -644,49 +646,3 @@ impl ScpFileStat { self.mode() & (libc::S_IFMT as i32) == (libc::S_IFREG as i32) } } - -// fn mkstat(stat: &libc::stat) -> old_io::FileStat { -// #[cfg(windows)] type Mode = libc::c_int; -// #[cfg(unix)] type Mode = libc::mode_t; -// -// // FileStat times are in milliseconds -// fn mktime(secs: u64, nsecs: u64) -> u64 { secs * 1000 + nsecs / 1000000 } -// -// #[cfg(all(not(target_os = "linux"), not(target_os = "android")))] -// fn flags(stat: &libc::stat) -> u64 { stat.st_flags as u64 } -// #[cfg(any(target_os = "linux", target_os = "android"))] -// fn flags(_stat: &libc::stat) -> u64 { 0 } -// -// #[cfg(all(not(target_os = "linux"), not(target_os = "android")))] -// fn gen(stat: &libc::stat) -> u64 { stat.st_gen as u64 } -// #[cfg(any(target_os = "linux", target_os = "android"))] -// fn gen(_stat: &libc::stat) -> u64 { 0 } -// -// old_io::FileStat { -// size: stat.st_size as u64, -// kind: match (stat.st_mode as Mode) & libc::S_IFMT { -// libc::S_IFREG => old_io::FileType::RegularFile, -// libc::S_IFDIR => old_io::FileType::Directory, -// libc::S_IFIFO => old_io::FileType::NamedPipe, -// libc::S_IFBLK => old_io::FileType::BlockSpecial, -// libc::S_IFLNK => old_io::FileType::Symlink, -// _ => old_io::FileType::Unknown, -// }, -// perm: old_io::FilePermission::from_bits_truncate(stat.st_mode as u32), -// created: mktime(stat.st_ctime as u64, stat.st_ctime_nsec as u64), -// modified: mktime(stat.st_mtime as u64, stat.st_mtime_nsec as u64), -// accessed: mktime(stat.st_atime as u64, stat.st_atime_nsec as u64), -// unstable: old_io::UnstableFileStat { -// device: stat.st_dev as u64, -// inode: stat.st_ino as u64, -// rdev: stat.st_rdev as u64, -// nlink: stat.st_nlink as u64, -// uid: stat.st_uid as u64, -// gid: stat.st_gid as u64, -// blksize: stat.st_blksize as u64, -// blocks: stat.st_blocks as u64, -// flags: flags(stat), -// gen: gen(stat), -// } -// } -// } diff --git a/tests/channel.rs b/tests/channel.rs index 94b7cf8..9cced14 100644 --- a/tests/channel.rs +++ b/tests/channel.rs @@ -106,3 +106,21 @@ fn forward() { assert_eq!(r, [4, 5, 6]); t.join().ok().unwrap(); } + +#[test] +fn drop_nonblocking() { + let listener = TcpListener::bind("127.0.0.1:0").unwrap(); + let addr = listener.local_addr().unwrap(); + + let (_tcp, sess) = ::authed_session(); + sess.set_blocking(false); + + let t = thread::spawn(move || { + let _s = listener.accept().unwrap(); + }); + + let _ = sess.channel_direct_tcpip("127.0.0.1", addr.port(), None); + drop(sess); + + t.join().unwrap(); +} |