Skip to content
Snippets Groups Projects
Commit b636a139 authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

fixed race conditions

parent a71d4d59
No related branches found
No related tags found
3 merge requests!123Refactor container deployment,!122Resolve "Data Race HTTP API",!90Develop
Pipeline #67388 passed with warnings
......@@ -47,19 +47,8 @@ func initialize() error {
}
// TODO: Start grpc listener here
if err := httpAPI(); err != nil {
return err
}
attachDatabase()
return nil
}
// deprecated
// attachDatabase connects to the database and passes the connection to the controller core
func attachDatabase() {
c.database = database.NewDatabaseClient()
return httpAPI()
}
// createSouthboundInterfaces initializes the controller with its supported SBIs
......
......@@ -9,12 +9,9 @@ import (
log "github.com/sirupsen/logrus"
"net/http"
"net/url"
"sync"
"time"
)
var httpOnce sync.Once
func stopHttpServer() error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
......@@ -35,15 +32,10 @@ func registerHttpHandler() {
// deprecated
func httpAPI() (err error) {
coreLock.Lock()
defer coreLock.Unlock()
httpOnce.Do(registerHttpHandler)
registerHttpHandler()
c.httpServer = &http.Server{Addr: ":8080"}
go func() {
err = c.httpServer.ListenAndServe()
if err != nil {
return
}
log.Info(c.httpServer.ListenAndServe())
}()
return nil
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment