mirror of
https://github.com/minio/minio.git
synced 2025-01-22 20:23:14 -05:00
Using RWMutex to guard closing and listeners (#3829)
This commit is contained in:
parent
2348ae7a19
commit
d1afd16955
@ -334,7 +334,7 @@ type ServerMux struct {
|
||||
// Time to wait before forcing server shutdown
|
||||
gracefulTimeout time.Duration
|
||||
|
||||
mu sync.Mutex // guards closing, and listeners
|
||||
mu sync.RWMutex // guards closing, and listeners
|
||||
closing bool
|
||||
}
|
||||
|
||||
@ -461,9 +461,9 @@ func (m *ServerMux) ListenAndServe(certFile, keyFile string) (err error) {
|
||||
|
||||
// Return ServiceUnavailable for clients which are sending requests
|
||||
// in shutdown phase
|
||||
m.mu.Lock()
|
||||
m.mu.RLock()
|
||||
closing := m.closing
|
||||
m.mu.Unlock()
|
||||
m.mu.RUnlock()
|
||||
if closing {
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user