fixed deadlock

This commit is contained in:
Timo Volkmann 2021-01-08 22:09:32 +01:00
parent 3ec0f58975
commit 1632419420
2 changed files with 11 additions and 1 deletions

View File

@ -63,8 +63,11 @@ func (p *pipelineReplay) channelFromTracking(t *Tracking) chan interface{} {
i++
}
}
logrus.Infoln("replay: tracking replay finished")
select {
case <-p.stopChan:
logrus.Debugln("replay pipeline closed")
}
}()
return ch
}

View File

@ -140,6 +140,7 @@ func (t *TrackingService) StartLivetracking(cols ...CollectorType) (string, erro
// finally create pipeline
NewRecordPipeline(t.publisher, t, tcp, ser)
t.publisher.SetStreaming(true)
logrus.Debugln("current State:", t.opMode)
return "LIVE", nil
}
@ -148,6 +149,7 @@ func (t *TrackingService) StartLivetracking(cols ...CollectorType) (string, erro
func (t *TrackingService) AllTrackings() ([]TrackingMetadata, error) {
logrus.Info("SERVICE: GET ALL TRACKINGS")
data, err := t.store.LoadAll()
logrus.Debugln("current State:", t.opMode)
return data, err
}
@ -168,6 +170,7 @@ func (t *TrackingService) StartRecord() (string, error) {
t.opMode = RECORDING
t.tracking.TimeCreated = time.Now()
t.SetRecording(true)
logrus.Debugln("current State:", t.opMode)
return "record started at: " + t.tracking.TimeCreated.String(), nil
}
@ -191,6 +194,7 @@ func (t *TrackingService) StopRecord() (*TrackingMetadata, error) {
tm := t.tracking.TrackingMetadata
t.safelyReplaceTracking(newTracking())
t.tracking.Collectors = tm.Collectors
logrus.Debugln("current State:", t.opMode)
return &tm, err
}
@ -214,12 +218,14 @@ func (t *TrackingService) StopAll() (*TrackingMetadata, error) {
tm, err = t.StopRecord()
}
t.opMode = STOPPED
logrus.Debugln("current State:", t.opMode)
return tm, err
}
// retrieves tracking with all data and starts replay pipeline if desired.
// in that case the application behaves like in live mode.
func (t *TrackingService) LoadTracking(trackingId uuid.UUID, replay bool) (*Tracking, error) {
logrus.Info("SERVICE: LOAD TRACKING")
if t.opMode == RECORDING {
txt := "trackingservice: please stop recording before load another tracking"
logrus.Warn(txt)
@ -245,6 +251,7 @@ func (t *TrackingService) LoadTracking(trackingId uuid.UUID, replay bool) (*Trac
t.replaypipe = NewReplayPipeline(t.publisher, t.tracking)
t.publisher.SetStreaming(true)
t.opMode = REPLAY
logrus.Debugln("current State:", t.opMode)
return t.tracking, nil
}