Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
remove rollback logic when writing reservation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Jul 10, 2021
1 parent c42f8b6 commit 958f509
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions v2/relay/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,12 @@ func (r *Relay) handleReserve(s network.Stream) {

log.Debugf("reserving relay slot for %s", p)

err := r.writeResponse(s, pbv2.Status_OK, r.makeReservationMsg(p, expire), r.makeLimitMsg(p))
if err != nil {
s.Reset()
// Delivery of the reservation might fail for a number of reasons.
// For example, the stream might be reset or the connection might be closed before the reservation is received.
// In that case, the reservation will just be garbage collected later.
if err := r.writeResponse(s, pbv2.Status_OK, r.makeReservationMsg(p, expire), r.makeLimitMsg(p)); err != nil {
log.Debugf("error writing reservation response; retracting reservation for %s", p)
r.mx.Lock()
delete(r.rsvp, p)
r.ipcs.RemoveReservation(p)
r.host.ConnManager().UntagPeer(p, "relay-reservation")
r.mx.Unlock()
s.Reset()
}
}

Expand Down

0 comments on commit 958f509

Please sign in to comment.