on master help sign in
catching up network 3.0.
commit5c9ccd5f69d5fa6715a7757cb01c12850d556f85 authorKazu Yamamoto <kazu@iij.ad.jp> dateMon 21 Jan 2019, 16:13 (8 years ago) parent74618ab
2 files changed+24−9
warp/Network/Wai/Handler/Warp/Recv.hs+17−8 warp/Network/Wai/Handler/Warp/Run.hs+7−1
warp/Network/Wai/Handler/Warp/Recv.hs+17−8
@@ -91,22 +91,31 @@ spell init0 siz0 recv recvBuf
9191
9292receive :: Socket -> BufferPool -> Recv
9393receive sock pool = withBufferPool pool $ \ (ptr, size) -> do
94− let sock' = fdSocket sock
95− size' = fromIntegral size
96− fromIntegral <$> receiveloop sock' ptr size'
94+#if MIN_VERSION_network(3,0,0)
95+ fd <- fdSocket sock
96+#else
97+ let fd = fdSocket sock
98+#endif
99+ let size' = fromIntegral size
100+ fromIntegral <$> receiveloop fd ptr size'
97101
98102receiveBuf :: Socket -> RecvBuf
99−receiveBuf sock buf0 siz0 = loop buf0 siz0
103+receiveBuf sock buf0 siz0 = do
104+#if MIN_VERSION_network(3,0,0)
105+ fd <- fdSocket sock
106+#else
107+ let fd = fdSocket sock
108+#endif
109+ loop fd buf0 siz0
100110 where
101− loop _ 0 = return True
102− loop buf siz = do
111+ loop _ _ 0 = return True
112+ loop fd buf siz = do
103113 n <- fromIntegral <$> receiveloop fd buf (fromIntegral siz)
104114 -- fixme: what should we do in the case of n == 0
105115 if n == 0 then
106116 return False
107117 else
108− loop (buf `plusPtr` n) (siz - n)
109− fd = fdSocket sock
118+ loop fd (buf `plusPtr` n) (siz - n)
110119
111120receiveloop :: CInt -> Ptr Word8 -> CSize -> IO CInt
112121receiveloop sock ptr size = do
warp/Network/Wai/Handler/Warp/Run.hs+7−1
@@ -536,7 +536,13 @@ setSocketCloseOnExec :: Socket -> IO ()
536536#if WINDOWS
537537setSocketCloseOnExec _ = return ()
538538#else
539−setSocketCloseOnExec socket = F.setFileCloseOnExec $ fromIntegral $ fdSocket socket
539+setSocketCloseOnExec socket = do
540+#if MIN_VERSION_network(3,0,0)
541+ fd <- fdSocket socket
542+#else
543+ let fd = fdSocket socket
544+#endif
545+ F.setFileCloseOnExec $ fromIntegral fd
540546#endif
541547
542548gracefulShutdown :: Settings -> Counter -> IO ()