Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/sockstate/netstat_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ func tcpSocks(accept AcceptFn) ([]sockTabEntry, error) {
}

func GetConnInode(c *net.TCPConn) (uint64, error) {
_, err := getConnFd(c)
_, finalize, err := getConnFd(c)
if err != nil {
return 0, err
}
defer finalize()
return 0, ErrSocketCheckNotImplemented.New()
}
3 changes: 2 additions & 1 deletion internal/sockstate/netstat_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ func tcpSocks(accept AcceptFn) ([]sockTabEntry, error) {
}

func GetConnInode(c *net.TCPConn) (uint64, error) {
_, err := getConnFd(c)
_, finalize, err := getConnFd(c)
if err != nil {
return 0, err
}
defer finalize()
return 0, ErrSocketCheckNotImplemented.New()
}
3 changes: 2 additions & 1 deletion internal/sockstate/netstat_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,11 @@ func tcpSocks(accept AcceptFn) ([]sockTabEntry, error) {

// GetConnInode returns the inode number of an fd.
func GetConnInode(conn *net.TCPConn) (n uint64, err error) {
fd, err := getConnFd(conn)
fd, finalize, err := getConnFd(conn)
if err != nil {
return 0, err
}
defer finalize()

if isWSL || isProcBlocked {
return 0, ErrSocketCheckNotImplemented.New()
Expand Down
8 changes: 3 additions & 5 deletions internal/sockstate/netstat_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"syscall"
)

func getConnFd(c *net.TCPConn) (fd uintptr, err error) {
func getConnFd(c *net.TCPConn) (fd uintptr, finalize func() error, err error) {
f, err := c.File()
if err != nil {
return 0, err
return 0, nil, err
}

fd = f.Fd()
Expand All @@ -34,7 +34,5 @@ func getConnFd(c *net.TCPConn) (fd uintptr, err error) {
// blocking Close() in some cases.
syscall.SetNonblock(int(fd), true)

f.Close()

return fd, nil
return fd, f.Close, nil
}