summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2015-05-28 15:21:08 -0700
committerCarl Lerche <me@carllerche.com>2015-05-28 15:21:08 -0700
commit663091bb2873fa45663b746bccefc85f223d13d6 (patch)
tree3b670fa618f99d55e752204773cfe49419610da8 /src/sys
parent6341927e3a58161c5f42e1b7291eea7c16dd4d02 (diff)
downloadnix-663091bb2873fa45663b746bccefc85f223d13d6.zip
Pass shutdown enum by value
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/socket/mod.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index affd7739..e00c8fe5 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -409,19 +409,23 @@ pub enum Shutdown {
/// Shut down part of a full-duplex connection.
///
/// [Further reading](http://man7.org/linux/man-pages/man2/shutdown.2.html)
-pub fn shutdown(df: Fd, how: &Shutdown) -> Result<()> {
+pub fn shutdown(df: Fd, how: Shutdown) -> Result<()> {
unsafe {
use libc::shutdown;
+
let how = match how {
- &Shutdown::Read => consts::SHUT_RD,
- &Shutdown::Write => consts::SHUT_WR,
- &Shutdown::Both => consts::SHUT_RDWR,
+ Shutdown::Read => consts::SHUT_RD,
+ Shutdown::Write => consts::SHUT_WR,
+ Shutdown::Both => consts::SHUT_RDWR,
};
+
let ret = shutdown(df, how);
+
if ret < 0 {
return Err(Error::last());
}
}
+
Ok(())
}