fixed weird behavior

This commit is contained in:
Timo Volkmann 2021-01-11 00:00:30 +01:00
parent 481f62fb6c
commit 9f91328c08
2 changed files with 14 additions and 6 deletions

View File

@ -23,9 +23,13 @@ func (p *pipelineReplay) Stop() {
logrus.Debugln("replay channel already closed")
}
}()
logrus.Debugln("send stop signal")
p.stopChan <- struct{}{}
logrus.Debugln("stop signal sent")
logrus.Debugln("send stop signal...")
select {
case p.stopChan <- struct{}{}:
logrus.Debugln("stop signal sent")
//default:
// logrus.Debugln("stop signal skipped")
}
}
func NewReplayPipeline(p Publisher, t *Tracking) *pipelineReplay {
@ -59,7 +63,7 @@ func (p *pipelineReplay) channelFromTracking(t *Tracking) chan interface{} {
if timeCounter >= durationSinceLastEvent {
select {
case <-p.stopChan:
logrus.Debugln("replay stopped")
logrus.Debugln("received stop signal: replay stopped")
break br
case ch <- &(t.Data[i]):
}
@ -72,7 +76,7 @@ func (p *pipelineReplay) channelFromTracking(t *Tracking) chan interface{} {
logrus.Infoln("replay: tracking replay finished")
select {
case <-p.stopChan:
logrus.Debugln("replay pipeline closed")
logrus.Debugln("received stop signal: replay pipeline closed")
}
close(p.replayChan)
}()

View File

@ -243,8 +243,12 @@ func (t *TrackingService) LoadTracking(trackingId uuid.UUID, replay bool) (*Trac
}
t.safelyReplaceTracking(*tracking)
if t.replaypipe != nil {
t.replaypipe.Stop()
t.replaypipe = nil
select {
case <-t.replaypipe.stopChan:
logrus.Warnln("blocking channel closed")
default:
}
}
t.replaypipe = NewReplayPipeline(t.publisher, t.tracking)
t.publisher.SetStreaming(true)