clean P2P protocol shutdown on EOF try 2

Same goal as b18fb1e343 but without
breaking backwards compatability. Just return IO exceptions when running
the P2P protocol, so that git-annex-shell can detect eof and avoid the
ugly message.

This commit was sponsored by Ethan Aubin.
This commit is contained in:
Joey Hess 2018-09-25 16:49:59 -04:00
parent 80defa62c6
commit 6134431254
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
8 changed files with 70 additions and 45 deletions

View file

@ -120,10 +120,10 @@ serveClient th u r q = bracket setup cleanup start
v <- liftIO $ runNetProto runstauth conn $ P2P.serveAuth u
case v of
Right (Just theiruuid) -> authed conn theiruuid
Right Nothing -> liftIO $
debugM "remotedaemon" "Tor connection failed to authenticate"
Left e -> liftIO $
debugM "remotedaemon" ("Tor connection error before authentication: " ++ e)
Right Nothing -> liftIO $ debugM "remotedaemon"
"Tor connection failed to authenticate"
Left e -> liftIO $ debugM "remotedaemon" $
"Tor connection error before authentication: " ++ describeProtoFailure e
-- Merge the duplicated state back in.
liftAnnex th $ mergeState st'
@ -134,7 +134,8 @@ serveClient th u r q = bracket setup cleanup start
P2P.serveAuthed P2P.ServeReadWrite u
case v' of
Right () -> return ()
Left e -> liftIO $ debugM "remotedaemon" ("Tor connection error: " ++ e)
Left e -> liftIO $ debugM "remotedaemon" $
"Tor connection error: " ++ describeProtoFailure e
-- Connect to peer's tor hidden service.
transport :: Transport