From f8d7666315c72e15ef01f3576bdbb0d000f17888 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Fri, 5 Jul 2024 16:29:32 +0000 Subject: [PATCH] mixclient: Do not submit PRs holding client mutex The client mutex was being held during the initial publishing of pair request messages to prevent a situation where a submit errored but the peer was still associated with the client, or the message was submitted to mixpool and sent to other peers but our local peer had not yet been associated to the client at the time an epoch tick occurred. This should not be a situation we will encounter anymore, since the PR submissions are spaced out intentionally to avoid sending them close to the epoch. --- mixing/mixclient/client.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mixing/mixclient/client.go b/mixing/mixclient/client.go index 8536d3e47..a1550ed41 100644 --- a/mixing/mixclient/client.go +++ b/mixing/mixclient/client.go @@ -744,8 +744,11 @@ func (c *Client) Dicemix(ctx context.Context, cj *CoinJoin) error { c.pairings[string(pairingID)] = pairing } pairing.localPeers[*p.id] = p + c.mu.Unlock() + err = p.submit(pr) if err != nil { + c.mu.Lock() delete(pairing.localPeers, *p.id) if len(pairing.localPeers) == 0 { delete(c.pairings, string(pairingID)) @@ -753,7 +756,6 @@ func (c *Client) Dicemix(ctx context.Context, cj *CoinJoin) error { c.mu.Unlock() return err } - c.mu.Unlock() select { case res := <-p.res: