fix: resolve RLock deadlock in Square mock client
Move m.mu.RUnlock to defer in GetCheckout and remove duplicate RLock/RUnlock around m.completed lookup. This prevents a deadlock when CheckoutPending error is returned but the RLock was already released. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -161,9 +161,9 @@ func (m *MockClient) GetCheckout(ctx context.Context, checkoutID string) (*Payme
|
||||
log.Printf("[SQUARE-MOCK] GetCheckout: id=%s", checkoutID)
|
||||
|
||||
m.mu.RLock()
|
||||
checkout, ok := m.checkouts[checkoutID]
|
||||
m.mu.RUnlock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
checkout, ok := m.checkouts[checkoutID]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("checkout not found: %s", checkoutID)
|
||||
}
|
||||
@@ -172,10 +172,7 @@ func (m *MockClient) GetCheckout(ctx context.Context, checkoutID string) (*Payme
|
||||
return nil, fmt.Errorf("checkout pending")
|
||||
}
|
||||
|
||||
m.mu.RLock()
|
||||
result, ok := m.completed[checkoutID]
|
||||
m.mu.RUnlock()
|
||||
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("checkout result not found: %s", checkoutID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user