summaryrefslogtreecommitdiffhomepage
path: root/Types.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-30 13:54:02 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-30 13:54:02 -0400
commitb47e621749257331788e82e44d1565cf4d32d04b (patch)
treed6c3445be85b05fc58675552fc1bfb4f0ceb375d /Types.hs
parent89d4e18cdb6ed1c3e7916dd66cf907bedf58a549 (diff)
downloaddebug-me-b47e621749257331788e82e44d1565cf4d32d04b.tar.gz
fix probable race in use of restoreHashes
I think there was a race where a SessionKey message had been drained from the TChan, but not yet added to the developer state, which was resonsible for recent instability at startup. It manifested as protocol errors where the prevActivity hash was wrongly Nothing. Fixed by adding a MissingHashes type to tag things whose hashes have been stripped, and adding back the hashes when needed, which always happens inside atomically blocks, so won't have such a race.
Diffstat (limited to 'Types.hs')
-rw-r--r--Types.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/Types.hs b/Types.hs
index 78c59a2..7622f6a 100644
--- a/Types.hs
+++ b/Types.hs
@@ -64,6 +64,10 @@ data Activity a = Activity
}
deriving (Show, Generic)
+-- | Used when a value has had its hashes erased for more efficient
+-- transfer over the wire.
+data MissingHashes a = MissingHashes a
+
instance DataSize a => DataSize (Activity a) where
dataSize a = dataSize (activity a)
+ maybe 0 dataSize (prevActivity a)