diff --git a/pkg/cmdtail/cmdtail.go b/pkg/cmdtail/cmdtail.go index b43e044d1..9bf1a6f54 100644 --- a/pkg/cmdtail/cmdtail.go +++ b/pkg/cmdtail/cmdtail.go @@ -44,14 +44,14 @@ func (w CmdWatchEntry) getTailPos(reqId string) (TailPos, bool) { return TailPos{}, false } -func (w *CmdWatchEntry) updateTailPos(reqId string, pos TailPos) { +func (w *CmdWatchEntry) updateTailPos(reqId string, newPos TailPos) { for idx, pos := range w.Tails { if pos.ReqId == reqId { - w.Tails[idx] = pos + w.Tails[idx] = newPos return } } - w.Tails = append(w.Tails, pos) + w.Tails = append(w.Tails, newPos) } func (w *CmdWatchEntry) removeTailPos(reqId string) { @@ -284,6 +284,10 @@ func (t *Tailer) Run() error { return err } +func (t *Tailer) Close() error { + return t.Watcher.Close() +} + func max(v1 int64, v2 int64) int64 { if v1 > v2 { return v1 @@ -304,9 +308,6 @@ func (entry *CmdWatchEntry) fillFilePos(scHomeDir string) { } func (t *Tailer) AddWatch(getPacket *packet.GetCmdPacketType) error { - if !getPacket.Tail { - return fmt.Errorf("cannot add a watch for non-tail packet") - } _, err := uuid.Parse(getPacket.SessionId) if err != nil { return fmt.Errorf("getcmd, bad sessionid '%s': %w", getPacket.SessionId, err) diff --git a/pkg/cmdtail/sessionwatcher.go b/pkg/cmdtail/sessionwatcher.go index 9f3bcf817..1e736cb89 100644 --- a/pkg/cmdtail/sessionwatcher.go +++ b/pkg/cmdtail/sessionwatcher.go @@ -58,6 +58,10 @@ func MakeSessionWatcher() (*SessionWatcher, error) { return rtn, nil } +func (w *SessionWatcher) Close() error { + return w.Watcher.Close() +} + func (w *SessionWatcher) UnWatchSession(sessionId string) error { _, err := uuid.Parse(sessionId) if err != nil {