break
}
+ // releaseSession() is equivalent to session.Release() except
+ // that it's a no-op if (1) session is nil, or (2) it has
+ // already been called.
+ //
+ // This way, we can do a defer call here to ensure it gets
+ // called in all code paths, and also call it inline (see
+ // below) in the cases where we want to release the lock
+ // before returning.
releaseSession := func() {}
if session != nil {
var releaseSessionOnce sync.Once
// When writing, we need to block session renewal
// until we're finished, in order to guarantee the
// effect of the write is visible in future responses.
- // But if we're not writing, we can release the lcok
+ // But if we're not writing, we can release the lock
// early. This enables us to keep renewing sessions
// and processing more requests even if a slow client
// takes a long time to download a large file.