fix: atomic.Value should be a concrete type to avoid panics (#13740)

Go's atomic.Value does not support `nil` type,
concrete type is necessary to avoid any panics with
the current implementation.

Also remove boolean to turn-off tracking of freezeCount.
This commit is contained in:
Harshavardhana
2021-11-23 16:09:28 -08:00
committed by GitHub
parent 91e0823ff0
commit 9ca25bd48f
2 changed files with 19 additions and 38 deletions

View File

@@ -228,7 +228,7 @@ func (t *apiConfig) getRequestsPool() (chan struct{}, time.Duration) {
func maxClients(f http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if val := globalServiceFreeze.Load(); val != nil {
if unlock, ok := val.(chan struct{}); ok {
if unlock, ok := val.(chan struct{}); ok && unlock != nil {
// Wait until unfrozen.
<-unlock
}