summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-11-09 23:27:07 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-11-09 23:27:07 -0400
commitdfa3da4efa401d0373d8e7062eb9045b9c54c474 (patch)
tree8807a43e830c677f23d1126a28b53f5c55d0a1b6 /Assistant
parent9a41d84989173a75e9fb28c00b2b224983a97ef3 (diff)
ensure handles get closed
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/XMPP/Git.hs18
1 files changed, 11 insertions, 7 deletions
diff --git a/Assistant/XMPP/Git.hs b/Assistant/XMPP/Git.hs
index 72af2758e..0ff6f3ed1 100644
--- a/Assistant/XMPP/Git.hs
+++ b/Assistant/XMPP/Git.hs
@@ -109,7 +109,10 @@ xmppPush cid remote refs = runPush (SendPushRunning cid) handleDeferred $ do
let params = Param name : map (Param . show) refs
ok <- liftIO $ Git.Command.runBool "push" params g'
- liftIO $ mapM_ killThread [t1, t2]
+ liftIO $ do
+ mapM_ killThread [t1, t2]
+ mapM_ hClose [inh, outh, controlh]
+
return ok
where
toxmpp inh = forever $ do
@@ -124,7 +127,7 @@ xmppPush cid remote refs = runPush (SendPushRunning cid) handleDeferred $ do
B.hPut outh b
hFlush outh
(ReceivePackDone _ exitcode) -> liftIO $ do
- hPutStrLn controlh (show exitcode)
+ hPrint controlh exitcode
hFlush controlh
_ -> noop
installwrapper tmpdir = liftIO $ do
@@ -204,15 +207,16 @@ xmppReceivePack cid = runPush (ReceivePushRunning cid) handleDeferred $ do
code <- waitForProcess pid
void $ sendexitcode code
killThread readertid
+ hClose inh
+ hClose outh
return $ code == ExitSuccess
where
toxmpp outh = do
b <- liftIO $ B.hGetSome outh chunkSize
- if B.null b
- then return () -- EOF
- else do
- sendNetMessage $ ReceivePackOutput cid b
- toxmpp outh
+ -- empty is EOF, so exit
+ unless (B.null b) $ do
+ sendNetMessage $ ReceivePackOutput cid b
+ toxmpp outh
fromxmpp inh = forever $ do
m <- waitNetPushMessage
case m of