on master help sign in
implementing free.
f7bd636Kazu Yamamoto
warp/Network/Wai/Handler/Warp/Run.hs+12−10
@@ -45,14 +45,16 @@ bytesPerRead :: Int
45bytesPerRead = 4096
45bytesPerRead = 4096
46
46
47-- | Default action value for 'Connection'
47-- | Default action value for 'Connection'
48−socketConnection :: Socket -> ReceiveBuffer -> Connection
48+socketConnection :: Socket -> IO Connection
49−socketConnection s buf = Connection
49+socketConnection s = do
50+ buf <- allocateRecvBuffer bytesPerRead
51+ return Connection {
50− { connSendMany = Sock.sendMany s
52+ connSendMany = Sock.sendMany s
51− , connSendAll = Sock.sendAll s
53+ , connSendAll = Sock.sendAll s
52− , connSendFile = sendFile s
54+ , connSendFile = sendFile s
53− , connClose = sClose s
55+ , connClose = sClose s >> freeRecvBuffer buf
54− , connRecv = receive s buf bytesPerRead
56+ , connRecv = receive s buf bytesPerRead
55− }
57+ }
56
58
57sendFile :: Socket -> FilePath -> Integer -> Integer -> IO () -> [ByteString] -> Cleaner -> IO ()
59sendFile :: Socket -> FilePath -> Integer -> Integer -> IO () -> [ByteString] -> Cleaner -> IO ()
58#if SENDFILEFD
60#if SENDFILEFD
@@ -111,9 +113,9 @@ runSettingsSocket set socket app =
111 where
113 where
112 getConn = do
114 getConn = do
113 (s, sa) <- accept socket
115 (s, sa) <- accept socket
114− buf <- allocateRecvBuffer bytesPerRead
115 setSocketCloseOnExec socket
116 setSocketCloseOnExec socket
117+ conn <- socketConnection s
116− return (socketConnection s buf, sa)
118+ return (conn, sa)
117
119
118runSettingsConnection :: Settings -> IO (Connection, SockAddr) -> Application -> IO ()
120runSettingsConnection :: Settings -> IO (Connection, SockAddr) -> Application -> IO ()
119runSettingsConnection set getConn app = runSettingsConnectionMaker set getConnMaker app
121runSettingsConnection set getConn app = runSettingsConnectionMaker set getConnMaker app