Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
danet
goSDN
Commits
44d01e0b
Commit
44d01e0b
authored
Mar 30, 2021
by
Manuel Kieweg
🤷
Browse files
add mutex fpr httpAPI start
parent
9e97138d
Changes
2
Hide whitespace changes
Inline
Side-by-side
nucleus/controller.go
View file @
44d01e0b
...
@@ -47,7 +47,8 @@ func initialize() error {
...
@@ -47,7 +47,8 @@ func initialize() error {
}
}
// TODO: Start grpc listener here
// TODO: Start grpc listener here
coreLock
.
Lock
()
defer
coreLock
.
Unlock
()
return
httpAPI
()
return
httpAPI
()
}
}
...
@@ -76,11 +77,9 @@ func createPrincipalNetworkDomain(sbi SouthboundInterface) error {
...
@@ -76,11 +77,9 @@ func createPrincipalNetworkDomain(sbi SouthboundInterface) error {
// Run calls initialize to start the controller
// Run calls initialize to start the controller
func
Run
(
ctx
context
.
Context
)
error
{
func
Run
(
ctx
context
.
Context
)
error
{
var
initError
error
var
initError
error
coreLock
.
Lock
()
coreOnce
.
Do
(
func
()
{
coreOnce
.
Do
(
func
()
{
initError
=
initialize
()
initError
=
initialize
()
})
})
coreLock
.
Unlock
()
if
initError
!=
nil
{
if
initError
!=
nil
{
log
.
WithFields
(
log
.
Fields
{})
.
Error
(
initError
)
log
.
WithFields
(
log
.
Fields
{})
.
Error
(
initError
)
return
initError
return
initError
...
...
nucleus/http_test.go
View file @
44d01e0b
...
@@ -137,10 +137,12 @@ func Test_httpApi(t *testing.T) {
...
@@ -137,10 +137,12 @@ func Test_httpApi(t *testing.T) {
wantErr
:
false
,
wantErr
:
false
,
},
},
}
}
coreLock
.
Lock
()
if
err
:=
httpAPI
();
err
!=
nil
{
if
err
:=
httpAPI
();
err
!=
nil
{
t
.
Errorf
(
"httpApi() error = %v"
,
err
)
t
.
Errorf
(
"httpApi() error = %v"
,
err
)
return
return
}
}
coreLock
.
Unlock
()
for
_
,
tt
:=
range
tests
{
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
got
,
err
:=
http
.
Get
(
tt
.
request
)
got
,
err
:=
http
.
Get
(
tt
.
request
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment