Skip to content

Commit

Permalink
make connimpl exported
Browse files Browse the repository at this point in the history
  • Loading branch information
smallnest committed Oct 7, 2023
1 parent c6fed93 commit d503971
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Binary file added .DS_Store
Binary file not shown.
13 changes: 7 additions & 6 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@ import (
)

// newConnImpl returns a net.Conn with GetFD() method.
func newConnImpl(in net.Conn) net.Conn {
if _, ok := in.(connImpl); ok {
return in
func newConnImpl(in net.Conn) ConnImpl {
if ci, ok := in.(ConnImpl); ok {
return ci
}

return connImpl{
return ConnImpl{
Conn: in,
fd: socketFD(in),
}
}

type connImpl struct {
// ConnImpl is a net.Conn with GetFD() method.
type ConnImpl struct {
net.Conn
fd int
}

func (c connImpl) GetFD() int {
func (c ConnImpl) GetFD() int {
return c.fd
}
2 changes: 1 addition & 1 deletion epoll.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func socketFD(conn net.Conn) int {
sfd = int(fd)
})
return sfd
} else if con, ok := conn.(connImpl); ok {
} else if con, ok := conn.(ConnImpl); ok {
return con.fd
}
return 0
Expand Down
2 changes: 1 addition & 1 deletion wepoll/epoll_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func socketFDAsUint(conn net.Conn) uint64 {
sfd = uint64(fd)
})
return sfd
} else if con, ok := conn.(connImpl); ok {
} else if con, ok := conn.(ConnImpl); ok {
return conn.GetFD()
}
return 0
Expand Down

0 comments on commit d503971

Please sign in to comment.