extend p2p protocol to support gitremote-helpers connect

A bit tricky since Proto doesn't support threads. Rather than adding
threading support to it, ended up using a callback that waits for both
data on a Handle, and incoming messages at the same time.

This commit was sponsored by Denis Dzyubenko on Patreon.
This commit is contained in:
Joey Hess 2016-11-19 16:30:57 -04:00
parent 9d9d1fdcd4
commit 0eaad7ca3a
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
2 changed files with 74 additions and 5 deletions

View file

@ -24,6 +24,7 @@ module Utility.SimpleProtocol (
import Data.Char
import GHC.IO.Handle
import System.Exit (ExitCode(..))
import Common
@ -95,3 +96,9 @@ dupIoHandles = do
instance Serializable [Char] where
serialize = id
deserialize = Just
instance Serializable ExitCode where
serialize ExitSuccess = "0"
serialize (ExitFailure n) = show n
deserialize "0" = Just ExitSuccess
deserialize s = ExitFailure <$> readish s