From 663091bb2873fa45663b746bccefc85f223d13d6 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Thu, 28 May 2015 15:21:08 -0700 Subject: Pass shutdown enum by value --- src/sys/socket/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') 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(()) } -- cgit v1.2.3