From 933817752806f78c4dc59ee7041610ba8052874a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Sun, 19 Feb 2023 09:10:18 +0100 Subject: [PATCH] feat(pcap): do not use closure in connection helper --- Pcap/NosSmooth.Pcap/TcpConnectionHelper.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Pcap/NosSmooth.Pcap/TcpConnectionHelper.cs b/Pcap/NosSmooth.Pcap/TcpConnectionHelper.cs index fdec6d35fc785804813c2e567322663b2b5fd4df..2211e19527b6e18843d6e2eeb8c7709f5eb30604 100644 --- a/Pcap/NosSmooth.Pcap/TcpConnectionHelper.cs +++ b/Pcap/NosSmooth.Pcap/TcpConnectionHelper.cs @@ -39,8 +39,18 @@ public static class TcpConnectionHelper foreach (var connection in tcpv4Connections) { - var process = processIds.FirstOrDefault(x => x == connection.OwningPid, -1); - if (process != -1) + var process = (int)connection.OwningPid; + var matches = false; + foreach (var processId in processIds) + { + if (connection.OwningPid == processId) + { + matches = true; + break; + } + } + + if (matches) { if (!result.ContainsKey(process)) {