From ff075ad99fed715306348a327234561f49cee0ff Mon Sep 17 00:00:00 2001 From: lesismal Date: Sat, 4 Dec 2021 01:56:00 +0800 Subject: [PATCH] #145: change nbhttp.Engine.Start order, fix race condition --- nbhttp/engine.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nbhttp/engine.go b/nbhttp/engine.go index 74a012de..f8e2e52d 100644 --- a/nbhttp/engine.go +++ b/nbhttp/engine.go @@ -329,12 +329,16 @@ func (e *Engine) stopListeners() { // Start . func (e *Engine) Start() error { - err := e.startListeners() + err := e.Gopher.Start() if err != nil { return err } - - return e.Gopher.Start() + err = e.startListeners() + if err != nil { + e.Gopher.Stop() + return err + } + return err } // Stop .