[+]优雅关机

This commit is contained in:
goodjava@qq.com
2018-06-29 13:20:09 +08:00
parent 23f9aa3479
commit 7678e66a84
2 changed files with 3 additions and 14 deletions

View File

@@ -617,11 +617,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// Close immediately closes all active net.Listeners.
func (s *Server) Close() error {
s.mu.Lock()
defer s.mu.Unlock()
s.closeDoneChanLocked()
var err error
if s.ln != nil {
err = s.ln.Close()
}
for c := range s.activeConn {
c.Close()
delete(s.activeConn, c)