Skip to content

Commit

Permalink
further speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Dec 20, 2023
1 parent ada83e2 commit 1896a4a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions psutil/arch/freebsd/sys_socks.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ int psutil_gather_inet(
goto error;
}

// filter
if ((inp->inp_vflag & INP_IPV4) && (include_v4 == 0))
continue;
if ((inp->inp_vflag & INP_IPV6) && (include_v6 == 0))
continue;

char lip[200], rip[200];

xf = psutil_get_file_from_sock(so->xso_so);
Expand All @@ -188,15 +194,11 @@ int psutil_gather_inet(
rport = ntohs(inp->inp_fport);

if (inp->inp_vflag & INP_IPV4) {
if (include_v4 == 0)
continue;
family = AF_INET;
inet_ntop(AF_INET, &inp->inp_laddr.s_addr, lip, sizeof(lip));
inet_ntop(AF_INET, &inp->inp_faddr.s_addr, rip, sizeof(rip));
}
else if (inp->inp_vflag & INP_IPV6) {
if (include_v6 == 0)
continue;
family = AF_INET6;
inet_ntop(AF_INET6, &inp->in6p_laddr.s6_addr, lip, sizeof(lip));
inet_ntop(AF_INET6, &inp->in6p_faddr.s6_addr, rip, sizeof(rip));
Expand Down

0 comments on commit 1896a4a

Please sign in to comment.