You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gethostbyaddr() obsoleted. Change to getaddrinfo()? #162
getnameinfo() combines gethostbyaddr() and getservbyport(), and currently in lsof, the latter is queried from both getservbyport() and the port mapper via rpc. I wonder if getnameinfo() queries the port mapper? The manpage does not reveal the detail, and I am unsure whether port map is still extensively used today.
Update: yes, port map is still used today, e.g. NFS server + rpcbind. The rpcbind process provides the port mapper. getservbyport()/getnameinfo() does not query port mapper via rpc.
Update 2: although gethostbyaddr() is obsoleted, it fits well in the current code: there is a host cache for gethostbyaddr(), a port cache for getservbyport() + port mapper. If we want to migrate to getaddrinfo(), we will need to merge the two calls and caches, or simply provide an empty port to gethostbyaddr() to only replace gethostbyaddr(). Is it worth it?
gethostbyaddr() is obsolete, but getaddrinfo() is not the correct replacement here; getnameinfo() is. However, because lsof intentionally keeps host lookup separate from service lookup and still relies on portmapper/rpcbind behavior, a full migration to getnameinfo() would not be behavior-preserving. Given that, I’d suggest closing this unless someone wants to implement a host-only getnameinfo() refactor without touching the existing service-resolution logic.
(should be POSIX-safe across platforms)