mirror of
https://github.com/zhaojh329/rttys.git
synced 2026-02-27 09:53:21 +08:00
When a new device connection is established, it creates a Device struct and checks for ID conflicts. If a conflict exists, the new device connection closes and triggers DelDevice via its defer statement. The original implementation used LoadAndDelete which removed any device with the given ID, causing the existing device to be incorrectly removed. This changes the deletion logic to use CompareAndDelete, which verifies both the device ID and the specific device instance. Now when a duplicate connection closes, only the new (unregistered) device is attempted for removal, preserving the existing device in the registry. This ensures legitimate devices remain connected when duplicate connection attempts occur. Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
2.1 KiB
2.1 KiB