@@ -133,8 +133,6 @@ runSettingsConnection set getConn app = runSettingsConnectionMaker set getConnMa
133133-- Since 1.3.5
134134runSettingsConnectionMaker :: Settings -> IO (IO Connection, SockAddr) -> Application -> IO ()
135135runSettingsConnectionMaker set getConn app = do
136− tm <- maybe (T.initialize $ settingsTimeout set * 1000000) return
137− $ settingsManager set
138136#if SENDFILEFD
139137 let duration = settingsFdCacheDuration set
140138 fc <- case duration of
@@ -159,7 +157,7 @@ runSettingsConnectionMaker set getConn app = do
159157 -- First mask all exceptions in the main loop. This is necessary to ensure
160158 -- that no async exception is throw between the call to getConnLoop and the
161159 -- registering of connClose.
162− mask_ . forever $ do
160+ withTimeoutManager $ \tm -> mask_ . forever $ do
163161 -- Allow async exceptions before receiving the next connection maker.
164162 allowInterrupt
165163
@@ -220,6 +218,14 @@ runSettingsConnectionMaker set getConn app = do
220218 onOpen = settingsOnOpen set
221219 onClose = settingsOnClose set
222220
221+ withTimeoutManager f =
222+ case settingsManager set of
223+ Nothing -> bracket
224+ (T.initialize $ settingsTimeout set * 1000000)
225+ T.stopManager
226+ f
227+ Just tm -> f tm
228+
223229serveConnection :: Settings
224230 -> Cleaner
225231 -> Port -> Application -> Connection -> SockAddr-> IO ()