More race fixes

This commit is contained in:
Leonid Bugaev
2015-08-20 09:27:44 +03:00
parent 6974a6e278
commit 3c45595a96
3 changed files with 10 additions and 13 deletions
+5 -1
View File
@@ -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))