Skip to content

Commit

Permalink
nil our peer msgs if the send fails (e.g. by context)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Dec 31, 2024
1 parent 2b658cb commit 60ede3d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 3 additions & 1 deletion mixing/mixclient/blame.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ func (c *Client) blame(ctx context.Context, sesRun *sessionRun) (err error) {
// initial peers who published secrets.
c.forLocalPeers(ctx, sesRun, func(p *peer) error {
if !p.triggeredBlame {
p.rs.SeenSecrets = rsHashes
if p.rs != nil {
p.rs.SeenSecrets = rsHashes
}
}
return nil
})
Expand Down
30 changes: 29 additions & 1 deletion mixing/mixclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,30 @@ func (c *Client) sendLocalPeerMsgs(ctx context.Context, s *sessionRun, msgMask u
return msgs[i].t.Before(msgs[j].t)
})

nilPeerMsg := func(p *peer, msgMask uint) {
if msgMask&msgKE == msgKE {
p.ke = nil
}
if msgMask&msgCT == msgCT {
p.ct = nil
}
if msgMask&msgSR == msgSR {
p.sr = nil
}
if msgMask&msgFP == msgFP {
p.fp = nil
}
if msgMask&msgDC == msgDC {
p.dc = nil
}
if msgMask&msgCM == msgCM {
p.cm = nil
}
if msgMask&msgRS == msgRS && p.rs != nil {
p.rs = nil
}
}

resChans := make([]chan error, 0, len(msgs))
for i := range msgs {
res := make(chan error, 1)
Expand All @@ -536,7 +560,11 @@ func (c *Client) sendLocalPeerMsgs(ctx context.Context, s *sessionRun, msgMask u
qsend := &queueWork{
p: m.p,
f: func(p *peer) error {
return p.signAndSubmit(m.m)
err := p.signAndSubmit(m.m)
if err != nil {
nilPeerMsg(p, msgMask)
}
return err
},
res: res,
}
Expand Down

0 comments on commit 60ede3d

Please sign in to comment.