You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The correct flow when negotiating a connection is:
Get a connection reservation.
Handshake/negotiate the connection.
On error, finish the reservation.
On success return a connection that will finish the reservation on connection .Close().
Currently for step 3, we are finishing the reservation in multiple code paths. This is error prone since it's easy to forget to finish a reservation somewhere and have a connection reservation leak. See #2025 for an example.
The fix here is to refactor the code so that the on error step always happens. The two approaches are to either:
Wrap the logic in another function, and finish the reservation by the caller on error.
Handle the error in a defer func (aka err defer).
1 is probably more idiomatic Go code, so prefer that.
The text was updated successfully, but these errors were encountered:
The correct flow when negotiating a connection is:
.Close()
.Currently for step 3, we are finishing the reservation in multiple code paths. This is error prone since it's easy to forget to finish a reservation somewhere and have a connection reservation leak. See #2025 for an example.
The fix here is to refactor the code so that the on error step always happens. The two approaches are to either:
defer
func (aka err defer).1 is probably more idiomatic Go code, so prefer that.
The text was updated successfully, but these errors were encountered: