fix(keystone): appsrv listen multi port failed cause of race condition

This commit is contained in:
Zexi Li
2021-08-26 16:49:28 +08:00
parent 28561dbea1
commit 00aa056e7d
2 changed files with 7 additions and 5 deletions
+6 -4
View File
@@ -65,6 +65,7 @@ type Application struct {
isExiting bool
idleConnsClosed chan struct{}
httpServer *http.Server
slaveHttpServer *http.Server
}
const (
@@ -464,15 +465,16 @@ func (app *Application) ListenAndServeWithoutCleanup(addr, certFile, keyFile str
}
func (app *Application) ListenAndServeTLSWithCleanup2(addr string, certFile, keyFile string, onStop func(), isMaster bool) {
httpSrv := app.initServer(addr)
if isMaster {
app.addDefaultHandlers()
AddPProfHandler(app)
}
app.httpServer = app.initServer(addr)
if isMaster {
app.httpServer = httpSrv
app.registerCleanShutdown(app.httpServer, onStop)
} else {
app.slaveHttpServer = httpSrv
}
app.listenAndServeInternal(app.httpServer, certFile, keyFile)
app.listenAndServeInternal(httpSrv, certFile, keyFile)
if isMaster {
app.waitCleanShutdown()
}
+1 -1
View File
@@ -53,7 +53,7 @@ func ServeForeverExtended(app *appsrv.Application, options *common_options.BaseO
if options.EnableSsl {
proto = "https"
}
log.Infof("Start listen on %s://%s", proto, addr)
log.Infof("Start listen on %s://%s, isMaster: %v", proto, addr, isMaster)
var certfile string
var sslfile string
if options.EnableSsl {