Skip to content

Commit

Permalink
using withFdSocket
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Aug 30, 2019
1 parent 0f20662 commit 209b133
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions warp/Network/Wai/Handler/Warp/Recv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ import Foreign.C.Types
import Foreign.ForeignPtr (withForeignPtr)
import Foreign.Ptr (Ptr, castPtr, plusPtr)
import GHC.Conc (threadWaitRead)
import Network.Socket (Socket, fdSocket)
import Network.Socket (Socket)
#if MIN_VERSION_network(3,1,0)
import Network.Socket (withFdSocket)
#else
import Network.Socket (fdSocket)
#endif
import System.Posix.Types (Fd(..))

import Network.Wai.Handler.Warp.Buffer
Expand Down Expand Up @@ -91,7 +96,9 @@ spell init0 siz0 recv recvBuf

receive :: Socket -> BufferPool -> Recv
receive sock pool = withBufferPool pool $ \ (ptr, size) -> do
#if MIN_VERSION_network(3,0,0)
#if MIN_VERSION_network(3,1,0)
withFdSocket sock $ \fd -> do
#elif MIN_VERSION_network(3,0,0)
fd <- fdSocket sock
#else
let fd = fdSocket sock
Expand All @@ -101,7 +108,9 @@ receive sock pool = withBufferPool pool $ \ (ptr, size) -> do

receiveBuf :: Socket -> RecvBuf
receiveBuf sock buf0 siz0 = do
#if MIN_VERSION_network(3,0,0)
#if MIN_VERSION_network(3,1,0)
withFdSocket sock $ \fd -> do
#elif MIN_VERSION_network(3,0,0)
fd <- fdSocket sock
#else
let fd = fdSocket sock
Expand Down

0 comments on commit 209b133

Please sign in to comment.