1
0
mirror of https://github.com/redis/go-redis.git synced 2025-12-03 18:31:14 +03:00

fix unsafe test

This commit is contained in:
Nedyalko Dyakov
2025-10-29 16:19:04 +02:00
parent 62eecaa75e
commit 43eeae70ab

View File

@@ -3,6 +3,7 @@ package pool_test
import (
"bufio"
"context"
"sync/atomic"
"unsafe"
. "github.com/bsm/ginkgo/v2"
@@ -129,9 +130,10 @@ var _ = Describe("Buffer Size Configuration", func() {
// cause runtime panics or incorrect memory access due to invalid pointer dereferencing.
func getWriterBufSizeUnsafe(cn *pool.Conn) int {
cnPtr := (*struct {
id uint64 // First field in pool.Conn
usedAt int64 // Second field (atomic)
netConnAtomic interface{} // atomic.Value (interface{} has same size)
id uint64 // First field in pool.Conn
usedAt atomic.Int64 // Second field (atomic)
lastPutAt atomic.Int64 // Third field (atomic)
netConnAtomic interface{} // atomic.Value (interface{} has same size)
rd *proto.Reader
bw *bufio.Writer
wr *proto.Writer
@@ -155,9 +157,10 @@ func getWriterBufSizeUnsafe(cn *pool.Conn) int {
func getReaderBufSizeUnsafe(cn *pool.Conn) int {
cnPtr := (*struct {
id uint64 // First field in pool.Conn
usedAt int64 // Second field (atomic)
netConnAtomic interface{} // atomic.Value (interface{} has same size)
id uint64 // First field in pool.Conn
usedAt atomic.Int64 // Second field (atomic)
lastPutAt atomic.Int64 // Third field (atomic)
netConnAtomic interface{} // atomic.Value (interface{} has same size)
rd *proto.Reader
bw *bufio.Writer
wr *proto.Writer