TrakHound / MTConnect.NET

Fully featured .NET library in C# to build MTConnect Agent, Adapter, and Client Applications. Pre-built Agents with Windows Installers. Support for Windows and Linux. Supports MTConnect Versions up to 2.3. Supports .NET Framework 4.6.1 up to .NET 8
http://www.TrakHound.com
MIT License
99 stars 39 forks source link

MD5 implementation is not thread safe #47

Closed SergeyGulik closed 1 year ago

SergeyGulik commented 1 year ago

MD5 implementation is not thread safe. As a result ChangeId sometimes got same value for different observations under heavy multi-threaded test. Made it thread-safe without blocking thread, but sacrificed some memory. My particular problem happened in MTConnectAgent private static bool FilterDelta where condition if (!ObjectExtensions.ByteArraysEqual(newObservation.ChangeId, existingObservation.ChangeId)) was false.

PatrickRitchie commented 1 year ago

Thanks for finding this issue. After some testing, it looks like this fix will work. I'll release a new version with this change included.