summaryrefslogtreecommitdiff
path: root/internal/server
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-08-28 19:36:46 +0100
committerPaul Buetow <paul@buetow.org>2021-08-28 19:36:46 +0100
commit6d727b9bdbc387c8a5c34406a2c4de9140face38 (patch)
treeb6638220853374536db3d32e862961e4dbaa820a /internal/server
parent9883a190109623b64e6d311dc2b462a6eae68003 (diff)
use a byte.Buffer in the file reader
Diffstat (limited to 'internal/server')
-rw-r--r--internal/server/handlers/serverhandler.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/internal/server/handlers/serverhandler.go b/internal/server/handlers/serverhandler.go
index 9541a34..62f3c2b 100644
--- a/internal/server/handlers/serverhandler.go
+++ b/internal/server/handlers/serverhandler.go
@@ -15,6 +15,7 @@ import (
"github.com/mimecast/dtail/internal/config"
"github.com/mimecast/dtail/internal/io/line"
"github.com/mimecast/dtail/internal/io/logger"
+ "github.com/mimecast/dtail/internal/io/pool"
"github.com/mimecast/dtail/internal/mapr/server"
"github.com/mimecast/dtail/internal/omode"
"github.com/mimecast/dtail/internal/protocol"
@@ -114,10 +115,10 @@ func (h *ServerHandler) Read(p []byte) (n int, err error) {
case line := <-h.lines:
//fmt.Printf("\t<<<%d,%s>>>\n", len(line.Content), line.Content)
// Send normal file content data as a message.
- serverInfo := []byte(fmt.Sprintf("REMOTE|%s|%3d|%v|%s|",
- h.hostname, line.TransmittedPerc, line.Count, line.SourceID))
- wholePayload := append(serverInfo, line.Content[:]...)
- n = copy(p, wholePayload)
+ payload := []byte(fmt.Sprintf("REMOTE|%s|%3d|%v|%s|%s",
+ h.hostname, line.TransmittedPerc, line.Count, line.SourceID, line.Content.String()))
+ n = copy(p, payload)
+ pool.RecycleBytesBuffer(line.Content)
return
case <-time.After(time.Second):