fix minor memory leak caused by recent CanPush change
Putting the UUID in meant that equivilant CanPush messages no longer are ==
This commit is contained in:
parent
c1f7774920
commit
4effef3176
2 changed files with 11 additions and 3 deletions
|
@ -32,8 +32,8 @@ notifyNetMessagerRestart =
|
|||
waitNetMessagerRestart :: Assistant ()
|
||||
waitNetMessagerRestart = readSV <<~ (netMessagerRestart . netMessager)
|
||||
|
||||
{- Store an important NetMessage for a client, and if the same message was
|
||||
- already sent, remove it from sentImportantNetMessages. -}
|
||||
{- Store an important NetMessage for a client, and if an equivilant
|
||||
- message was already sent, remove it from sentImportantNetMessages. -}
|
||||
storeImportantNetMessage :: NetMessage -> ClientID -> (ClientID -> Bool) -> Assistant ()
|
||||
storeImportantNetMessage m client matchingclient = go <<~ netMessager
|
||||
where
|
||||
|
@ -45,7 +45,7 @@ storeImportantNetMessage m client matchingclient = go <<~ netMessager
|
|||
putTMVar (sentImportantNetMessages nm) $
|
||||
M.mapWithKey removematching sent
|
||||
removematching someclient s
|
||||
| matchingclient someclient = S.delete m s
|
||||
| matchingclient someclient = S.filter (not . equivilantImportantNetMessages m) s
|
||||
| otherwise = s
|
||||
|
||||
{- Indicates that an important NetMessage has been sent to a client. -}
|
||||
|
|
|
@ -64,6 +64,14 @@ isImportantNetMessage (Pushing c (CanPush _ _)) = Just c
|
|||
isImportantNetMessage (Pushing c (PushRequest _)) = Just c
|
||||
isImportantNetMessage _ = Nothing
|
||||
|
||||
{- Checks if two important NetMessages are equivilant.
|
||||
- That is to say, assuming they were sent to the same client,
|
||||
- would it do the same thing for one as for the other? -}
|
||||
equivilantImportantNetMessages :: NetMessage -> NetMessage -> Bool
|
||||
equivilantImportantNetMessages (Pushing _ (CanPush _ _)) (Pushing _ (CanPush _ _)) = True
|
||||
equivilantImportantNetMessages (Pushing _ (PushRequest _)) (Pushing _ (PushRequest _)) = True
|
||||
equivilantImportantNetMessages _ _ = False
|
||||
|
||||
readdressNetMessage :: NetMessage -> ClientID -> NetMessage
|
||||
readdressNetMessage (PairingNotification stage _ uuid) c = PairingNotification stage c uuid
|
||||
readdressNetMessage (Pushing _ stage) c = Pushing c stage
|
||||
|
|
Loading…
Reference in a new issue