From 7158b72a03efee994a7e824317afbfdb4dc59caf Mon Sep 17 00:00:00 2001 From: yedajiang44 <602830483@qq.com> Date: Wed, 7 Aug 2024 21:36:30 +0800 Subject: [PATCH] review --- src/JT808.Protocol/Internal/DefaultMerger.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/JT808.Protocol/Internal/DefaultMerger.cs b/src/JT808.Protocol/Internal/DefaultMerger.cs index d28099b..819e8ea 100644 --- a/src/JT808.Protocol/Internal/DefaultMerger.cs +++ b/src/JT808.Protocol/Internal/DefaultMerger.cs @@ -44,7 +44,9 @@ public bool TryMerge(JT808Header header, byte[] data, IJT808Config config, out J body = null; var timeoutKey = GenerateKey(header.TerminalPhoneNo, header.MsgId); if (!CheckTimeout(timeoutKey)) return false; - timeoutDictionary.TryAdd(timeoutKey, DateTime.Now.AddSeconds(config.AutoMergeTimeoutSecond)); + var timeout = DateTime.Now.AddSeconds(config.AutoMergeTimeoutSecond); + if (timeoutDictionary.TryAdd(timeoutKey, timeout)) + timeoutDictionary.TryUpdate(timeoutKey, timeout, timeout); if (splitPackageDictionary.TryGetValue(header.TerminalPhoneNo, out var item) && item.TryGetValue(header.MsgId, out var packages)) { packages.Add((header.PackageIndex, data));