aboutsummaryrefslogtreecommitdiffstats
path: root/swarm
diff options
context:
space:
mode:
authorJanoš Guljaš <janos@users.noreply.github.com>2019-01-24 19:02:47 +0800
committerRafael Matias <rafael@skyle.net>2019-02-19 19:56:30 +0800
commitb774d0a507017b2ba7a0d02f6aa23a0a83d1a768 (patch)
treeee6ac0d3956fefa24c6b5075d281ee3a24ce2199 /swarm
parent4976fcc91a43b5c7047c51a03985887b694f0fbb (diff)
downloaddexon-b774d0a507017b2ba7a0d02f6aa23a0a83d1a768.tar.gz
dexon-b774d0a507017b2ba7a0d02f6aa23a0a83d1a768.tar.zst
dexon-b774d0a507017b2ba7a0d02f6aa23a0a83d1a768.zip
swarm: fix a data race on startTime (#18511)
(cherry picked from commit fa34429a2695f57bc0a96cd78f25e86700d8ee44)
Diffstat (limited to 'swarm')
-rw-r--r--swarm/swarm.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/swarm/swarm.go b/swarm/swarm.go
index d17d81320..9ece8bb66 100644
--- a/swarm/swarm.go
+++ b/swarm/swarm.go
@@ -56,7 +56,6 @@ import (
)
var (
- startTime time.Time
updateGaugesPeriod = 5 * time.Second
startCounter = metrics.NewRegisteredCounter("stack,start", nil)
stopCounter = metrics.NewRegisteredCounter("stack,stop", nil)
@@ -80,6 +79,7 @@ type Swarm struct {
swap *swap.Swap
stateStore *state.DBStore
accountingMetrics *protocols.AccountingMetrics
+ startTime time.Time
tracerClose io.Closer
}
@@ -344,7 +344,7 @@ Start is called when the stack is started
*/
// implements the node.Service interface
func (self *Swarm) Start(srv *p2p.Server) error {
- startTime = time.Now()
+ self.startTime = time.Now()
self.tracerClose = tracing.Closer
@@ -414,7 +414,7 @@ func (self *Swarm) periodicallyUpdateGauges() {
}
func (self *Swarm) updateGauges() {
- uptimeGauge.Update(time.Since(startTime).Nanoseconds())
+ uptimeGauge.Update(time.Since(self.startTime).Nanoseconds())
requestsCacheGauge.Update(int64(self.netStore.RequestsCacheLen()))
}