Skip to content

Commit 65d38a8

Browse files
committed
Increment Scanner's ThreadGroup when starting the stats thread, so the main goroutine will wait for it to finish up.
1 parent 3fd5845 commit 65d38a8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

workers/scanner.go

+5
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ func (s *Scanner) threadedScanAndPin() {
250250

251251
// Start a thread that will print intermediate scanning statistics.
252252
statsCh := make(chan struct{})
253+
err = s.staticTG.Add()
254+
if err != nil {
255+
return // the threadgroup is stopped
256+
}
253257
go s.threadedPrintStats(statsCh)
254258

255259
// Start N threads that will scan for underpinned skylinks and repin
@@ -279,6 +283,7 @@ func (s *Scanner) threadedScanAndPin() {
279283
// threadedPrintStats prints regular updates on the scanning process plus a
280284
// final overview of the pinned and skipped skylinks.
281285
func (s *Scanner) threadedPrintStats(stopCh chan struct{}) {
286+
defer s.staticTG.Done()
282287
intermediateStatsTicker := time.NewTicker(printPinningStatisticsPeriod)
283288
defer intermediateStatsTicker.Stop()
284289

0 commit comments

Comments
 (0)