on master help sign in
using withFdSocket
209b133Kazu Yamamoto
warp/Network/Wai/Handler/Warp/Recv.hs+12−3
@@ -17,7 +17,12 @@ import Foreign.C.Types
17import Foreign.ForeignPtr (withForeignPtr)
17import Foreign.ForeignPtr (withForeignPtr)
18import Foreign.Ptr (Ptr, castPtr, plusPtr)
18import Foreign.Ptr (Ptr, castPtr, plusPtr)
19import GHC.Conc (threadWaitRead)
19import GHC.Conc (threadWaitRead)
20−import Network.Socket (Socket, fdSocket)
20+import Network.Socket (Socket)
21+#if MIN_VERSION_network(3,1,0)
22+import Network.Socket (withFdSocket)
23+#else
24+import Network.Socket (fdSocket)
25+#endif
21import System.Posix.Types (Fd(..))
26import System.Posix.Types (Fd(..))
22
27
23import Network.Wai.Handler.Warp.Buffer
28import Network.Wai.Handler.Warp.Buffer
@@ -91,7 +96,9 @@ spell init0 siz0 recv recvBuf
91
96
92receive :: Socket -> BufferPool -> Recv
97receive :: Socket -> BufferPool -> Recv
93receive sock pool = withBufferPool pool $ \ (ptr, size) -> do
98receive sock pool = withBufferPool pool $ \ (ptr, size) -> do
94−#if MIN_VERSION_network(3,0,0)
99+#if MIN_VERSION_network(3,1,0)
100+ withFdSocket sock $ \fd -> do
101+#elif MIN_VERSION_network(3,0,0)
95 fd <- fdSocket sock
102 fd <- fdSocket sock
96#else
103#else
97 let fd = fdSocket sock
104 let fd = fdSocket sock
@@ -101,7 +108,9 @@ receive sock pool = withBufferPool pool $ \ (ptr, size) -> do
101
108
102receiveBuf :: Socket -> RecvBuf
109receiveBuf :: Socket -> RecvBuf
103receiveBuf sock buf0 siz0 = do
110receiveBuf sock buf0 siz0 = do
104−#if MIN_VERSION_network(3,0,0)
111+#if MIN_VERSION_network(3,1,0)
112+ withFdSocket sock $ \fd -> do
113+#elif MIN_VERSION_network(3,0,0)
105 fd <- fdSocket sock
114 fd <- fdSocket sock
106#else
115#else
107 let fd = fdSocket sock
116 let fd = fdSocket sock