loopd: synchronize cached swap lookups

This commit is contained in:
Gustavo Stingelin 2026-07-15 14:20:45 -03:00
parent 34cf98e8e8
commit 7200a7ce09
No known key found for this signature in database
GPG key ID: 15CBADFE29F2017B

View file

@ -785,10 +785,13 @@ func (s *swapClientServer) SwapInfo(ctx context.Context,
// Just return the server's in-memory cache here too as we also want to
// return temporary failures to the client.
s.swapsLock.Lock()
swp, ok := s.swaps[swapHash]
s.swapsLock.Unlock()
if !ok {
return nil, fmt.Errorf("swap with hash %s not found", req.Id)
}
return s.marshallSwap(ctx, &swp)
}