* move "httpsServer" to "config"

This commit is contained in:
Simon Zolin
2019-07-09 18:50:17 +03:00
parent f79008d9d0
commit 2780ace63e
4 changed files with 28 additions and 25 deletions

View File

@@ -46,7 +46,7 @@ func handleTLSValidate(w http.ResponseWriter, r *http.Request) {
// check if port is available
// BUT: if we are already using this port, no need
alreadyRunning := false
if httpsServer.server != nil {
if config.httpsServer.server != nil {
alreadyRunning = true
}
if !alreadyRunning {
@@ -72,7 +72,7 @@ func handleTLSConfigure(w http.ResponseWriter, r *http.Request) {
// check if port is available
// BUT: if we are already using this port, no need
alreadyRunning := false
if httpsServer.server != nil {
if config.httpsServer.server != nil {
alreadyRunning = true
}
if !alreadyRunning {
@@ -101,12 +101,12 @@ func handleTLSConfigure(w http.ResponseWriter, r *http.Request) {
if restartHTTPS {
go func() {
time.Sleep(time.Second) // TODO: could not find a way to reliably know that data was fully sent to client by https server, so we wait a bit to let response through before closing the server
httpsServer.cond.L.Lock()
httpsServer.cond.Broadcast()
if httpsServer.server != nil {
httpsServer.server.Shutdown(context.TODO())
config.httpsServer.cond.L.Lock()
config.httpsServer.cond.Broadcast()
if config.httpsServer.server != nil {
config.httpsServer.server.Shutdown(context.TODO())
}
httpsServer.cond.L.Unlock()
config.httpsServer.cond.L.Unlock()
}()
}
}