remove rollback logic when writing reservation fails

This commit is contained in:
Marten Seemann 2021-07-06 12:34:47 -07:00
parent b44b6de1b8
commit 7a72c33aef
1 changed files with 5 additions and 8 deletions

View File

@ -175,15 +175,12 @@ func (r *Relay) handleReserve(s network.Stream) {
log.Debugf("reserving relay slot for %s", p) log.Debugf("reserving relay slot for %s", p)
err := r.writeResponse(s, pbv2.Status_OK, r.makeReservationMsg(p, expire), r.makeLimitMsg(p)) // Delivery of the reservation might fail for a number of reasons.
if err != nil { // For example, the stream might be reset or the connection might be closed before the reservation is received.
s.Reset() // 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) log.Debugf("error writing reservation response; retracting reservation for %s", p)
r.mx.Lock() s.Reset()
delete(r.rsvp, p)
r.ipcs.RemoveReservation(p)
r.host.ConnManager().UntagPeer(p, "relay-reservation")
r.mx.Unlock()
} }
} }