33 lines
938 B
Diff
33 lines
938 B
Diff
From bedebc75e1f88d02e737203b09041c39094d5777 Mon Sep 17 00:00:00 2001
|
|
From: Irine Sistiana <49315432+IrineSistiana@users.noreply.github.com>
|
|
Date: Thu, 21 Sep 2023 11:04:03 +0800
|
|
Subject: [PATCH 4/6] pool: fixed PackTCPBuffer always re-allocate
|
|
|
|
---
|
|
pkg/pool/msg_buf.go | 3 ++-
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/pkg/pool/msg_buf.go b/pkg/pool/msg_buf.go
|
|
index f132cc2..11faf7d 100644
|
|
--- a/pkg/pool/msg_buf.go
|
|
+++ b/pkg/pool/msg_buf.go
|
|
@@ -60,13 +60,14 @@ func PackTCPBuffer(m *dns.Msg) (buf *[]byte, err error) {
|
|
return nil, fmt.Errorf("dns payload size %d is too large", l)
|
|
}
|
|
|
|
- if &((*b)[0]) != &wire[0] { // reallocated
|
|
+ if &((*b)[2]) != &wire[0] { // reallocated
|
|
ReleaseBuf(b)
|
|
b = GetBuf(l + 2)
|
|
binary.BigEndian.PutUint16((*b)[:2], uint16(l))
|
|
copy((*b)[2:], wire)
|
|
return b, nil
|
|
}
|
|
+ binary.BigEndian.PutUint16((*b)[:2], uint16(l))
|
|
*b = (*b)[:2+l]
|
|
return b, nil
|
|
}
|
|
--
|
|
2.34.8
|
|
|