mirror of
https://github.com/minio/minio.git
synced 2025-11-21 02:09:08 -05:00
server-mux: Rewrite graceful shutdown mechanism (#3771)
Old code uses waitgroup Add() and Wait() in different threads, which eventually can lead to a race.
This commit is contained in:
committed by
Harshavardhana
parent
d12f3e06b1
commit
7e84c7427d
@@ -198,21 +198,27 @@ func TestServerMux(t *testing.T) {
|
||||
time.Sleep(1 * time.Second)
|
||||
// Check if one listener is ready
|
||||
m.mu.Lock()
|
||||
if len(m.listeners) == 0 {
|
||||
m.mu.Unlock()
|
||||
listenersCount := len(m.listeners)
|
||||
m.mu.Unlock()
|
||||
if listenersCount == 0 {
|
||||
continue
|
||||
}
|
||||
m.mu.Lock()
|
||||
listenerAddr := m.listeners[0].Addr().String()
|
||||
m.mu.Unlock()
|
||||
// Issue the GET request
|
||||
client := http.Client{}
|
||||
m.mu.Lock()
|
||||
res, err = client.Get("http://" + m.listeners[0].Addr().String())
|
||||
m.mu.Unlock()
|
||||
res, err = client.Get("http://" + listenerAddr)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
// Read the request response
|
||||
got, err = ioutil.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
// We've got a response, quit the loop
|
||||
break
|
||||
}
|
||||
|
||||
// Check for error persisted after 5 times
|
||||
|
||||
Reference in New Issue
Block a user