diff --git a/emitter.go b/emitter.go index 8ad053c..d767d45 100644 --- a/emitter.go +++ b/emitter.go @@ -32,17 +32,6 @@ func Start(stop chan int) { for { select { case <-stop: - for _, in := range Plugins.Inputs { - if c, ok := in.(io.Closer); ok { - c.Close() - } - } - - for _, out := range Plugins.Outputs { - if c, ok := out.(io.Closer); ok { - c.Close() - } - } return case <-time.After(time.Second): } diff --git a/input_file.go b/input_file.go index 840c5d7..24ebd2d 100644 --- a/input_file.go +++ b/input_file.go @@ -74,6 +74,10 @@ func (i *FileInput) emit() { lastTime = ts } - i.data <- buf + // scanner returs only pointer, so to remove data-race we have to allocate new array + newBuf := make([]byte, len(buf)) + copy(newBuf, buf) + + i.data <- newBuf } } diff --git a/output_tcp.go b/output_tcp.go index 96295dc..9d46fa7 100644 --- a/output_tcp.go +++ b/output_tcp.go @@ -62,7 +62,11 @@ func (o *TCPOutput) Write(data []byte) (n int, err error) { return len(data), nil } - o.buf <- data + // We have to copy, because sending data in multiple threads + newBuf := make([]byte, len(data)) + copy(newBuf, data) + + o.buf <- newBuf if Settings.outputTCPStats { o.bufStats.Write(len(o.buf))