From c339416862dc56e9772c721bcd1b1d3a05de384c Mon Sep 17 00:00:00 2001 From: Rok Mandeljc Date: Fri, 20 Apr 2018 20:14:26 +0200 Subject: [PATCH] Replay service: stop running tasks when a replay is deleted Fixes #1895. --- services/replay/service.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/services/replay/service.go b/services/replay/service.go index 97b2a99cf..5ad259e7c 100644 --- a/services/replay/service.go +++ b/services/replay/service.go @@ -806,7 +806,19 @@ func (s *Service) handleDeleteReplay(w http.ResponseWriter, req *http.Request) { httpd.HttpError(w, err.Error(), true, http.StatusBadRequest) return } - //TODO: Cancel running replays + + // Cancel running replays + replay, err := s.replays.Get(id) + if err == nil { + tm := s.TaskMasterLookup.Get(replay.ID) + if tm != nil { + for _, b := range tm.BatchCollectors(replay.TaskID) { + b.Close() + } + tm.StopTasks() + } + } + s.replays.Delete(id) w.WriteHeader(http.StatusNoContent) }