fixed weird behavior
This commit is contained in:
parent
481f62fb6c
commit
9f91328c08
@ -23,9 +23,13 @@ func (p *pipelineReplay) Stop() {
|
|||||||
logrus.Debugln("replay channel already closed")
|
logrus.Debugln("replay channel already closed")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
logrus.Debugln("send stop signal")
|
logrus.Debugln("send stop signal...")
|
||||||
p.stopChan <- struct{}{}
|
select {
|
||||||
logrus.Debugln("stop signal sent")
|
case p.stopChan <- struct{}{}:
|
||||||
|
logrus.Debugln("stop signal sent")
|
||||||
|
//default:
|
||||||
|
// logrus.Debugln("stop signal skipped")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewReplayPipeline(p Publisher, t *Tracking) *pipelineReplay {
|
func NewReplayPipeline(p Publisher, t *Tracking) *pipelineReplay {
|
||||||
@ -59,7 +63,7 @@ func (p *pipelineReplay) channelFromTracking(t *Tracking) chan interface{} {
|
|||||||
if timeCounter >= durationSinceLastEvent {
|
if timeCounter >= durationSinceLastEvent {
|
||||||
select {
|
select {
|
||||||
case <-p.stopChan:
|
case <-p.stopChan:
|
||||||
logrus.Debugln("replay stopped")
|
logrus.Debugln("received stop signal: replay stopped")
|
||||||
break br
|
break br
|
||||||
case ch <- &(t.Data[i]):
|
case ch <- &(t.Data[i]):
|
||||||
}
|
}
|
||||||
@ -72,7 +76,7 @@ func (p *pipelineReplay) channelFromTracking(t *Tracking) chan interface{} {
|
|||||||
logrus.Infoln("replay: tracking replay finished")
|
logrus.Infoln("replay: tracking replay finished")
|
||||||
select {
|
select {
|
||||||
case <-p.stopChan:
|
case <-p.stopChan:
|
||||||
logrus.Debugln("replay pipeline closed")
|
logrus.Debugln("received stop signal: replay pipeline closed")
|
||||||
}
|
}
|
||||||
close(p.replayChan)
|
close(p.replayChan)
|
||||||
}()
|
}()
|
||||||
|
|||||||
@ -243,8 +243,12 @@ func (t *TrackingService) LoadTracking(trackingId uuid.UUID, replay bool) (*Trac
|
|||||||
}
|
}
|
||||||
t.safelyReplaceTracking(*tracking)
|
t.safelyReplaceTracking(*tracking)
|
||||||
if t.replaypipe != nil {
|
if t.replaypipe != nil {
|
||||||
t.replaypipe.Stop()
|
|
||||||
t.replaypipe = nil
|
t.replaypipe = nil
|
||||||
|
select {
|
||||||
|
case <-t.replaypipe.stopChan:
|
||||||
|
logrus.Warnln("blocking channel closed")
|
||||||
|
default:
|
||||||
|
}
|
||||||
}
|
}
|
||||||
t.replaypipe = NewReplayPipeline(t.publisher, t.tracking)
|
t.replaypipe = NewReplayPipeline(t.publisher, t.tracking)
|
||||||
t.publisher.SetStreaming(true)
|
t.publisher.SetStreaming(true)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user