Skip to content

Commit

Permalink
Fix TestIfSocketCloses
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Jul 31, 2022
1 parent 553085a commit 5a0e524
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nl/nl_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"reflect"
"testing"
"time"
_ "unsafe"

"golang.org/x/sys/unix"
)
Expand Down Expand Up @@ -63,6 +64,9 @@ func TestIfInfomsgDeserializeSerialize(t *testing.T) {
testDeserializeSerialize(t, orig, safemsg, msg)
}

//go:linkname errFileClosing internal/poll.ErrFileClosing
var errFileClosing error

func TestIfSocketCloses(t *testing.T) {
nlSock, err := Subscribe(unix.NETLINK_ROUTE, unix.RTNLGRP_NEIGH)
if err != nil {
Expand All @@ -74,8 +78,7 @@ func TestIfSocketCloses(t *testing.T) {
endCh <- nil
for {
_, _, err := sk.Receive()
// Receive returned because of a timeout and the FD == -1 means that the socket got closed
if err == unix.EAGAIN && nlSock.GetFd() == -1 {
if err == errFileClosing {
endCh <- err
return
}
Expand Down

0 comments on commit 5a0e524

Please sign in to comment.