summaryrefslogtreecommitdiff
path: root/Assistant/Types
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-10 18:39:56 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-10 18:39:56 -0400
commit9a418f32746c551833136726c052ea2d9549538a (patch)
treec2d7806cbf23b4220b5cc8f56fb2f4634d772c01 /Assistant/Types
parent8102072f091e394e9e4dbae515c9965b34745563 (diff)
assistant: Added sequence numbers to XMPP git push packets. (Not yet used.)
For backwards compatability, "" is treated as "0" sequence number. --debug will show xmpp sequence numbers now, but they are not otherwise used.
Diffstat (limited to 'Assistant/Types')
-rw-r--r--Assistant/Types/NetMessager.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/Assistant/Types/NetMessager.hs b/Assistant/Types/NetMessager.hs
index 1ea7db7ce..57ed52024 100644
--- a/Assistant/Types/NetMessager.hs
+++ b/Assistant/Types/NetMessager.hs
@@ -42,13 +42,18 @@ data PushStage
-- indicates that a push is starting
| StartingPush
-- a chunk of output of git receive-pack
- | ReceivePackOutput ByteString
+ | ReceivePackOutput SequenceNum ByteString
-- a chuck of output of git send-pack
- | SendPackOutput ByteString
+ | SendPackOutput SequenceNum ByteString
-- sent when git receive-pack exits, with its exit code
| ReceivePackDone ExitCode
deriving (Show, Eq, Ord)
+{- A sequence number. Incremented by one per packet in a sequence,
+ - starting with 1 for the first packet. 0 means sequence numbers are
+ - not being used. -}
+type SequenceNum = Int
+
{- NetMessages that are important (and small), and should be stored to be
- resent when new clients are seen. -}
isImportantNetMessage :: NetMessage -> Maybe ClientID
@@ -64,8 +69,8 @@ readdressNetMessage m _ = m
{- Convert a NetMessage to something that can be logged. -}
sanitizeNetMessage :: NetMessage -> NetMessage
sanitizeNetMessage (Pushing c stage) = Pushing c $ case stage of
- ReceivePackOutput _ -> ReceivePackOutput elided
- SendPackOutput _ -> SendPackOutput elided
+ ReceivePackOutput n _ -> ReceivePackOutput n elided
+ SendPackOutput n _ -> SendPackOutput n elided
s -> s
where
elided = B8.pack "<elided>"
@@ -85,8 +90,8 @@ pushDestinationSide :: PushStage -> PushSide
pushDestinationSide CanPush = ReceivePack
pushDestinationSide PushRequest = SendPack
pushDestinationSide StartingPush = ReceivePack
-pushDestinationSide (ReceivePackOutput _) = SendPack
-pushDestinationSide (SendPackOutput _) = ReceivePack
+pushDestinationSide (ReceivePackOutput _ _) = SendPack
+pushDestinationSide (SendPackOutput _ _) = ReceivePack
pushDestinationSide (ReceivePackDone _) = SendPack
type SideMap a = PushSide -> a