fix tailx data race
@@ -259,6 +259,15 @@ func (ar *ActiveReader) Run() {
}
}
}
+
+func (ar *ActiveReader) isStopping() bool {
+ return atomic.LoadInt32(&ar.status) == StatusStopping
+}
+
+func (ar *ActiveReader) hasStopped() bool {
+ return atomic.LoadInt32(&ar.status) == StatusStopped
+}
+
func (ar *ActiveReader) Close() error {
defer log.Warnf("Runner[%v] ActiveReader %s was closed", ar.runnerName, ar.originpath)
brCloseErr := ar.br.Close()
@@ -278,6 +287,9 @@ func (ar *ActiveReader) sendError(err error) {
if err == nil {
return
}
+ if ar.isStopping() || ar.hasStopped() {
+ return
+ }
defer func() {
if r := recover(); r != nil {
log.Errorf("Runner[%v] ActiveReader %s Recovered from %v", ar.runnerName, ar.originpath, r)
