yesod-core: In handlerToIO, really avoid keeping old handler data in memory.
This commit is contained in:
parent
933ad50ac3
commit
5b19865c7a
@ -438,6 +438,12 @@ handlerToIO =
|
|||||||
newWaiReq = oldWaiReq { W.requestBody = mempty }
|
newWaiReq = oldWaiReq { W.requestBody = mempty }
|
||||||
newReq = oldReq { reqWaiRequest = newWaiReq
|
newReq = oldReq { reqWaiRequest = newWaiReq
|
||||||
, reqBodySize = 0 }
|
, reqBodySize = 0 }
|
||||||
|
clearedOldHandlerData =
|
||||||
|
oldHandlerData { handlerRequest = err "handlerRequest never here"
|
||||||
|
, handlerState = err "handlerState never here" }
|
||||||
|
where
|
||||||
|
err :: String -> a
|
||||||
|
err = error . ("handlerToIO: clearedOldHandlerData/" ++)
|
||||||
newState <- liftIO $ do
|
newState <- liftIO $ do
|
||||||
oldState <- I.readIORef (handlerState oldHandlerData)
|
oldState <- I.readIORef (handlerState oldHandlerData)
|
||||||
return $ oldState { ghsRBC = Nothing
|
return $ oldState { ghsRBC = Nothing
|
||||||
@ -450,8 +456,9 @@ handlerToIO =
|
|||||||
-- The state IORef needs to be created here, otherwise it
|
-- The state IORef needs to be created here, otherwise it
|
||||||
-- will be shared by different invocations of this function.
|
-- will be shared by different invocations of this function.
|
||||||
newStateIORef <- I.newIORef newState
|
newStateIORef <- I.newIORef newState
|
||||||
runResourceT $ f oldHandlerData { handlerRequest = newReq
|
runResourceT $ f clearedOldHandlerData
|
||||||
, handlerState = newStateIORef }
|
{ handlerRequest = newReq
|
||||||
|
, handlerState = newStateIORef }
|
||||||
|
|
||||||
|
|
||||||
-- | Function used internally by Yesod in the process of converting a
|
-- | Function used internally by Yesod in the process of converting a
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user