summaryrefslogtreecommitdiff
path: root/Crypto.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-04-19 14:45:19 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-04-19 14:45:19 -0400
commita441e08da1e6305f36db782ec9eda44f213ffa29 (patch)
tree7f2c0fbbdf9dd779cb020faed1614bbd6f69eabc /Crypto.hs
parent1687fecd33ff73a71b2084532e9731796758047a (diff)
Fix stalls in S3 when transferring encrypted data.
Stalls were caused by code that did approximatly: content' <- liftIO $ withEncryptedContent cipher content return store content' The return evaluated without actually reading content from S3, and so the cleanup code began waiting on gpg to exit before gpg could send all its data. Fixing it involved moving the `store` type action into the IO monad: liftIO $ withEncryptedContent cipher content store Which was a bit of a pain to do, thank you type system, but avoids the problem as now the whole content is consumed, and stored, before cleanup.
Diffstat (limited to 'Crypto.hs')
-rw-r--r--Crypto.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/Crypto.hs b/Crypto.hs
index 1f4493b94..41f6b999b 100644
--- a/Crypto.hs
+++ b/Crypto.hs
@@ -199,7 +199,10 @@ gpgPipeStrict params input = do
return output
{- Runs gpg with a cipher and some parameters, feeding it an input,
- - and passing a handle to its output to an action. -}
+ - and passing a handle to its output to an action.
+ -
+ - Note that to avoid deadlock with the cleanup stage,
+ - the action must fully consume gpg's input before returning. -}
gpgCipherHandle :: [CommandParam] -> Cipher -> L.ByteString -> (Handle -> IO a) -> IO a
gpgCipherHandle params c input a = do
-- pipe the passphrase into gpg on a fd