Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
e59c47b7
Commit
e59c47b7
authored
4 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
fixes to the health tracker stopper
parent
e53af121
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
network/health/tracker.go
+7
-11
7 additions, 11 deletions
network/health/tracker.go
stoppable/cleanup.go
+1
-1
1 addition, 1 deletion
stoppable/cleanup.go
with
8 additions
and
12 deletions
network/health/tracker.go
+
7
−
11
View file @
e59c47b7
...
...
@@ -103,7 +103,6 @@ func (t *Tracker) setHealth(h bool) {
func
(
t
*
Tracker
)
Start
()
(
stoppable
.
Stoppable
,
error
)
{
t
.
mux
.
Lock
()
defer
t
.
mux
.
Unlock
()
if
t
.
running
{
return
nil
,
errors
.
New
(
"cannot start Health tracker threads, "
+
"they are already running"
)
...
...
@@ -111,20 +110,13 @@ func (t *Tracker) Start() (stoppable.Stoppable, error) {
t
.
running
=
true
t
.
isHealthy
=
false
t
.
mux
.
Unlock
()
stop
:=
stoppable
.
NewSingle
(
"Health Tracker"
)
stopCleanup
:=
stoppable
.
NewCleanup
(
stop
,
func
(
duration
time
.
Duration
)
error
{
t
.
mux
.
Lock
()
defer
t
.
mux
.
Unlock
()
t
.
isHealthy
=
false
t
.
transmit
(
false
)
t
.
running
=
false
return
nil
})
go
t
.
start
(
stop
.
Quit
())
return
stop
Cleanup
,
nil
return
stop
,
nil
}
// Long-running thread used to monitor and report on network health
...
...
@@ -135,7 +127,11 @@ func (t *Tracker) start(quitCh <-chan struct{}) {
var
heartbeat
network
.
Heartbeat
select
{
case
<-
quitCh
:
// Handle thread kill
t
.
mux
.
Lock
()
t
.
isHealthy
=
false
t
.
running
=
false
t
.
mux
.
Unlock
()
t
.
transmit
(
false
)
break
case
heartbeat
=
<-
t
.
heartbeat
:
if
healthy
(
heartbeat
)
{
...
...
This diff is collapsed.
Click to expand it.
stoppable/cleanup.go
+
1
−
1
View file @
e59c47b7
...
...
@@ -9,11 +9,11 @@ package stoppable
import
(
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/xx_network/primitives/netTime"
"sync"
"sync/atomic"
"time"
jww
"github.com/spf13/jwalterweatherman"
)
// Cleanup wraps any stoppable and runs a callback after to stop for cleanup
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment