Skip to content

Commit

Permalink
fix unlock panic
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Feb 7, 2025
1 parent 402c730 commit 79d3e73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fix_a_potential_panic_when_rpclock_fails.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: patch
---

# Fix a potential panic when rpcLock fails
3 changes: 1 addition & 2 deletions rhp/v2/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,16 @@ func (sh *SessionHandler) rpcLock(s *session, log *zap.Logger) (contracts.Usage,
return contracts.Usage{}, err
}

// set the contract
s.contract = contract
lockResp := &rhp2.RPCLockResponse{
Acquired: true,
NewChallenge: newChallenge,
Revision: contract.Revision,
Signatures: contract.Signatures(),
}
// avoid holding lock during network round trip
if err := s.writeResponse(lockResp, 30*time.Second); err != nil {
sh.contracts.Unlock(contract.Revision.ParentID)
s.contract = contracts.SignedRevision{}
return contracts.Usage{}, fmt.Errorf("failed to write lock response: %w", err)
}
return contracts.Usage{}, nil
Expand Down

0 comments on commit 79d3e73

Please sign in to comment.