mirror of
https://github.com/octoleo/syncthing.git
synced 2025-04-02 15:51:51 +00:00
cmd/stdiscosrv: Unflake test (fixes #5247)
This commit is contained in:
parent
3c657d1749
commit
c1f1fd71fe
@ -162,10 +162,10 @@ func (s *levelDBStore) Serve() {
|
|||||||
// Start the statistics serve routine. It will exit with us when
|
// Start the statistics serve routine. It will exit with us when
|
||||||
// statisticsTrigger is closed.
|
// statisticsTrigger is closed.
|
||||||
statisticsTrigger := make(chan struct{})
|
statisticsTrigger := make(chan struct{})
|
||||||
defer close(statisticsTrigger)
|
|
||||||
statisticsDone := make(chan struct{})
|
statisticsDone := make(chan struct{})
|
||||||
go s.statisticsServe(statisticsTrigger, statisticsDone)
|
go s.statisticsServe(statisticsTrigger, statisticsDone)
|
||||||
|
|
||||||
|
loop:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case fn := <-s.inbox:
|
case fn := <-s.inbox:
|
||||||
@ -184,12 +184,18 @@ func (s *levelDBStore) Serve() {
|
|||||||
|
|
||||||
case <-s.stop:
|
case <-s.stop:
|
||||||
// We're done.
|
// We're done.
|
||||||
return
|
close(statisticsTrigger)
|
||||||
|
break loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Also wait for statisticsServe to return
|
||||||
|
<-statisticsDone
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *levelDBStore) statisticsServe(trigger <-chan struct{}, done chan<- struct{}) {
|
func (s *levelDBStore) statisticsServe(trigger <-chan struct{}, done chan<- struct{}) {
|
||||||
|
defer close(done)
|
||||||
|
|
||||||
for range trigger {
|
for range trigger {
|
||||||
t0 := time.Now()
|
t0 := time.Now()
|
||||||
nowNanos := t0.UnixNano()
|
nowNanos := t0.UnixNano()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user