mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-13 19:46:39 +00:00
swarm: fix a data race on startTime (#18511)
This commit is contained in:
parent
bbd120354a
commit
fa34429a26
1 changed files with 3 additions and 3 deletions
|
|
@ -56,7 +56,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
startTime time.Time
|
|
||||||
updateGaugesPeriod = 5 * time.Second
|
updateGaugesPeriod = 5 * time.Second
|
||||||
startCounter = metrics.NewRegisteredCounter("stack,start", nil)
|
startCounter = metrics.NewRegisteredCounter("stack,start", nil)
|
||||||
stopCounter = metrics.NewRegisteredCounter("stack,stop", nil)
|
stopCounter = metrics.NewRegisteredCounter("stack,stop", nil)
|
||||||
|
|
@ -80,6 +79,7 @@ type Swarm struct {
|
||||||
swap *swap.Swap
|
swap *swap.Swap
|
||||||
stateStore *state.DBStore
|
stateStore *state.DBStore
|
||||||
accountingMetrics *protocols.AccountingMetrics
|
accountingMetrics *protocols.AccountingMetrics
|
||||||
|
startTime time.Time
|
||||||
|
|
||||||
tracerClose io.Closer
|
tracerClose io.Closer
|
||||||
}
|
}
|
||||||
|
|
@ -344,7 +344,7 @@ Start is called when the stack is started
|
||||||
*/
|
*/
|
||||||
// implements the node.Service interface
|
// implements the node.Service interface
|
||||||
func (self *Swarm) Start(srv *p2p.Server) error {
|
func (self *Swarm) Start(srv *p2p.Server) error {
|
||||||
startTime = time.Now()
|
self.startTime = time.Now()
|
||||||
|
|
||||||
self.tracerClose = tracing.Closer
|
self.tracerClose = tracing.Closer
|
||||||
|
|
||||||
|
|
@ -414,7 +414,7 @@ func (self *Swarm) periodicallyUpdateGauges() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Swarm) updateGauges() {
|
func (self *Swarm) updateGauges() {
|
||||||
uptimeGauge.Update(time.Since(startTime).Nanoseconds())
|
uptimeGauge.Update(time.Since(self.startTime).Nanoseconds())
|
||||||
requestsCacheGauge.Update(int64(self.netStore.RequestsCacheLen()))
|
requestsCacheGauge.Update(int64(self.netStore.RequestsCacheLen()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue