Skip to content

Commit 8d46631

Browse files
committed
fix: bugs
1 parent 922c272 commit 8d46631

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

connstate/conn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func ListenConnState(conn net.Conn) (ConnStater, error) {
5858
err = rawConn.Control(func(fileDescriptor uintptr) {
5959
fd = pollcache.alloc()
6060
fd.fd = int(fileDescriptor)
61-
fd.conn = unsafe.Pointer(&connStater{fd: unsafe.Pointer(fd)})
61+
atomic.StorePointer(&fd.conn, unsafe.Pointer(&connStater{fd: unsafe.Pointer(fd)}))
6262
opAddErr = poll.control(fd, opAdd)
6363
})
6464
if fd != nil {
@@ -75,7 +75,7 @@ func ListenConnState(conn net.Conn) (ConnStater, error) {
7575
if opAddErr != nil {
7676
return nil, opAddErr
7777
}
78-
return (*connStater)(fd.conn), nil
78+
return (*connStater)(atomic.LoadPointer(&fd.conn)), nil
7979
}
8080

8181
type connStater struct {

connstate/poll_bsd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type kqueue struct {
2727
fd int
2828
}
2929

30+
//go:nocheckptr
3031
func (p *kqueue) wait() error {
3132
events := make([]syscall.Kevent_t, 1024)
3233
for {

connstate/poll_linux.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type epoller struct {
2828
epfd int
2929
}
3030

31+
//go:nocheckptr
3132
func (p *epoller) wait() error {
3233
events := make([]syscall.EpollEvent, 1024)
3334
for {

0 commit comments

Comments
 (0)