Permalink
Browse files

Separate connClose and connFree

Thanks to @lehins for figuring out that this was causing the segfault
  • Loading branch information...
snoyberg committed Jan 24, 2017
1 parent 3eb5866 commit b63ec0e865cf91af4143416adaf430969ba0ebb5
@@ -345,6 +345,7 @@ httpOverTls TLSSettings{..} s bs0 params = do
, connSendAll = sendall
, connSendFile = sendfile
, connClose = close'
, connFree = freeBuffer writeBuf
, connRecv = recv ref
, connRecvBuf = recvBuf ref
, connWriteBuffer = writeBuf
@@ -355,8 +356,7 @@ httpOverTls TLSSettings{..} s bs0 params = do
sendfile fid offset len hook headers =
readSendFile writeBuf bufferSize sendall fid offset len hook headers
close' = freeBuffer writeBuf `finally`
void (tryIO $ TLS.bye ctx) `finally`
close' = void (tryIO $ TLS.bye ctx) `finally`
TLS.contextClose ctx
-- TLS version of recv with a cache for leftover input data.
View
@@ -21,7 +21,7 @@ Library
Build-Depends: base >= 4 && < 5
, bytestring >= 0.9
, wai >= 3.2 && < 3.3
, warp >= 3.2 && < 3.3
, warp >= 3.2.10 && < 3.3
, data-default-class >= 0.0.1
, tls >= 1.3.5
, cryptonite >= 0.12
View
@@ -1,3 +1,9 @@
## 3.2.10
* Add `connFree` to `Connection`
* Close socket connections on timeout triggered
* Timeout exceptions extend from `SomeAsyncException`
## 3.2.9
* Fixing a space leak. [#586] https://github.com/yesodweb/wai/pull/586
@@ -64,7 +64,8 @@ socketConnection s = do
connSendMany = Sock.sendMany s
, connSendAll = sendall
, connSendFile = sendFile s writeBuf bufferSize sendall
, connClose = close s >> freeBuffer writeBuf
, connClose = close s
, connFree = freeBuffer writeBuf
, connRecv = receive s bufferPool
, connRecvBuf = receiveBuf s
, connWriteBuffer = writeBuf
@@ -277,7 +278,8 @@ fork set mkConn addr app counter ii0 = settingsFork set $ \ unmask ->
-- We grab the connection before registering timeouts since the
-- timeouts will be useless during connection creation, due to the
-- fact that async exceptions are still masked.
bracket mkConn (closeConn ref . fst) $ \(conn, transport) ->
bracket mkConn (\(conn, _) -> closeConn ref conn `finally` connFree conn)
$ \(conn, transport) ->
-- We need to register a timeout handler for this thread, and
-- cancel that handler as soon as we exit. We additionally close
@@ -92,8 +92,13 @@ data Connection = Connection {
, connSendAll :: ByteString -> IO ()
-- | The sending function for files in HTTP/1.1.
, connSendFile :: SendFile
-- | The connection closing function.
-- | The connection closing function. Warp guarantees it will only be
-- called once. Other functions (like 'connRecv') may be called after
-- 'connClose' is called.
, connClose :: IO ()
-- | Free any buffers allocated. Warp guarantees it will only be
-- called once, and no other functions will be called after it.
, connFree :: IO ()
-- | The connection receiving function. This returns "" for EOF.
, connRecv :: Recv
-- | The connection receiving function. This tries to fill the buffer.
View
@@ -1,5 +1,5 @@
Name: warp
Version: 3.2.9
Version: 3.2.10
Synopsis: A fast, light-weight web server for WAI applications.
License: MIT
License-file: LICENSE

0 comments on commit b63ec0e

Please sign in to comment.