Skip to content

Commit

Permalink
add uninterruptibleErrorlessClose
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewthad committed Jan 18, 2019
1 parent 26bd2c4 commit 904854e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Posix/Socket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module Posix.Socket
-- ** Close
, close
, uninterruptibleClose
, uninterruptibleErrorlessClose
-- ** Shutdown
, uninterruptibleShutdown
-- ** Send
Expand Down Expand Up @@ -731,6 +732,19 @@ uninterruptibleClose ::
-> IO (Either Errno ())
uninterruptibleClose fd = c_unsafe_close fd >>= errorsFromInt

-- | Close a socket with the unsafe FFI. Do not check for errors. It is only
-- appropriate to use this when a socket is being closed to handle an
-- exceptional case. Since the user will want the propogate the original
-- exception, the exception provided by 'uninterruptibleClose' would just
-- be discarded. This function allows us to potentially avoid an additional
-- FFI call to 'getErrno'.
uninterruptibleErrorlessClose ::
Fd -- ^ Socket
-> IO ()
uninterruptibleErrorlessClose fd = do
_ <- c_unsafe_close fd
pure ()

-- | Shutdown a socket. This uses the unsafe FFI.
uninterruptibleShutdown ::
Fd
Expand Down

0 comments on commit 904854e

Please sign in to comment.