on master help sign in
Move exception handling to top of thread (fixes #613)

This is a long-standing bug, but hardly manifested until 3eb586636b7f0a9a8e4b4ad456c16efe23847c9e landed. With that change, the bracket function calls outside of the unmask were likely to receive an async timeout exception. Without a wrapping call to settingsOnException, these would be printed to the console, which isn't desired. Moving the handle call to the top of the thread ensures that any exception which occurs inside the thread has the handler applied.

commit35ef1ca27ec50025198dfe6c7f5eabac95d3498f authorMichael Snoyman <michael@snoyman.com> dateThu 23 Feb 2017, 13:28 (10 years ago) parent242a868
3 files changed+10−5
warp/ChangeLog.md+5 warp/Network/Wai/Handler/Warp/Run.hs+4−4 warp/warp.cabal+1−1
warp/ChangeLog.md+5
@@ -1,3 +1,8 @@
1+## 3.2.11.1
2+
3+* Move exception handling to top of thread (fixes
4+ [#613](https://github.com/yesodweb/wai/issues/613))
5+
16## 3.2.11
27
38* Fixing 10 HTTP2 bugs pointed out by h2spec v2.
warp/Network/Wai/Handler/Warp/Run.hs+4−4
@@ -264,6 +264,10 @@ fork :: Settings
264264 -> InternalInfo0
265265 -> IO ()
266266fork set mkConn addr app counter ii0 = settingsFork set $ \ unmask ->
267+ -- Call the user-supplied on exception code if any
268+ -- exceptions are thrown.
269+ handle (settingsOnException set Nothing) .
270+
267271 -- Allocate a new IORef indicating whether the connection has been
268272 -- closed, to avoid double-freeing a connection
269273 withClosedRef $ \ref ->
@@ -292,10 +296,6 @@ fork set mkConn addr app counter ii0 = settingsFork set $ \ unmask ->
292296 -- in the case of all exceptions, so it is safe to one
293297 -- again allow async exceptions.
294298 in unmask .
295− -- Call the user-supplied on exception code if any
296− -- exceptions are thrown.
297− handle (settingsOnException set Nothing) .
298−
299299 -- Call the user-supplied code for connection open and close events
300300 bracket (onOpen addr) (onClose addr) $ \goingon ->
301301
warp/warp.cabal+1−1
@@ -1,5 +1,5 @@
11Name: warp
2−Version: 3.2.11
2+Version: 3.2.11.1
33Synopsis: A fast, light-weight web server for WAI applications.
44License: MIT
55License-file: LICENSE