detect EOF on socket and cleanly shutdown the service process

This commit is contained in:
Joey Hess 2016-11-21 21:45:56 -04:00
parent 483dbcdbef
commit 2da338bb8d
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
2 changed files with 3 additions and 2 deletions

View file

@ -168,14 +168,14 @@ relayHelper runner v hin = loop
return (Just exitcode)
-- Takes input from the peer, and puts it into the MVar for processing.
-- Repeats until the peer tells it it's done.
-- Repeats until the peer tells it it's done or hangs up.
relayFeeder :: RunProto -> MVar RelayData -> IO ()
relayFeeder runner v = loop
where
loop = do
mrd <- runner $ net relayFromPeer
case mrd of
Nothing -> return ()
Nothing -> putMVar v (RelayDone (ExitFailure 1))
Just rd -> do
putMVar v rd
case rd of

View file

@ -47,3 +47,4 @@ server th@(TransportHandle (LocalRepo r) _) = do
h <- torHandle conn
_ <- runNetProtoHandle h h r (serve u)
hClose h
debugM "remotedaemon" "done handling a connection"