mirror of
https://github.com/redis/go-redis.git
synced 2025-12-02 06:22:31 +03:00
fix unsafe test
This commit is contained in:
@@ -3,6 +3,7 @@ package pool_test
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
|
"sync/atomic"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
. "github.com/bsm/ginkgo/v2"
|
. "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.
|
// cause runtime panics or incorrect memory access due to invalid pointer dereferencing.
|
||||||
func getWriterBufSizeUnsafe(cn *pool.Conn) int {
|
func getWriterBufSizeUnsafe(cn *pool.Conn) int {
|
||||||
cnPtr := (*struct {
|
cnPtr := (*struct {
|
||||||
id uint64 // First field in pool.Conn
|
id uint64 // First field in pool.Conn
|
||||||
usedAt int64 // Second field (atomic)
|
usedAt atomic.Int64 // Second field (atomic)
|
||||||
netConnAtomic interface{} // atomic.Value (interface{} has same size)
|
lastPutAt atomic.Int64 // Third field (atomic)
|
||||||
|
netConnAtomic interface{} // atomic.Value (interface{} has same size)
|
||||||
rd *proto.Reader
|
rd *proto.Reader
|
||||||
bw *bufio.Writer
|
bw *bufio.Writer
|
||||||
wr *proto.Writer
|
wr *proto.Writer
|
||||||
@@ -155,9 +157,10 @@ func getWriterBufSizeUnsafe(cn *pool.Conn) int {
|
|||||||
|
|
||||||
func getReaderBufSizeUnsafe(cn *pool.Conn) int {
|
func getReaderBufSizeUnsafe(cn *pool.Conn) int {
|
||||||
cnPtr := (*struct {
|
cnPtr := (*struct {
|
||||||
id uint64 // First field in pool.Conn
|
id uint64 // First field in pool.Conn
|
||||||
usedAt int64 // Second field (atomic)
|
usedAt atomic.Int64 // Second field (atomic)
|
||||||
netConnAtomic interface{} // atomic.Value (interface{} has same size)
|
lastPutAt atomic.Int64 // Third field (atomic)
|
||||||
|
netConnAtomic interface{} // atomic.Value (interface{} has same size)
|
||||||
rd *proto.Reader
|
rd *proto.Reader
|
||||||
bw *bufio.Writer
|
bw *bufio.Writer
|
||||||
wr *proto.Writer
|
wr *proto.Writer
|
||||||
|
|||||||
Reference in New Issue
Block a user