SDDP devices fire DeviceFound event even if the device is already know. #2008

Closed
opened 2026-02-06 21:37:16 +03:00 by OVERLORD · 0 comments
Owner

Originally created by @BaronGreenback on GitHub (Aug 4, 2020).

Logging this as a placeholder - whilst i fully test the implications.

Seen this multiple time - the same device is processed numerous times as the following function assumes even a repeat device is new.

private bool AddOrUpdateDiscoveredDevice(DiscoveredSsdpDevice device, IPAddress localIpAddress)
        {
            bool isNewDevice = false;
            lock (_devices)
            {
                var existingDevice = FindExistingDeviceNotification(_devices, device.NotificationType, device.Usn);
                if (existingDevice == null)
                {
                    _devices.Add(device);
                    isNewDevice = true;
                }
                else
                {
                    _devices.Remove(existingDevice);
                    _devices.Add(device);
                }
            }

            DeviceFound(device, isNewDevice, localIpAddress);

            return isNewDevice;
        }

Fix is wrap DeviceFound with

            if (isNewDevice)
            {
                 DeviceFound(device, isNewDevice, localIpAddress);
            }
Originally created by @BaronGreenback on GitHub (Aug 4, 2020). Logging this as a placeholder - whilst i fully test the implications. Seen this multiple time - the same device is processed numerous times as the following function assumes even a repeat device is new. ``` private bool AddOrUpdateDiscoveredDevice(DiscoveredSsdpDevice device, IPAddress localIpAddress) { bool isNewDevice = false; lock (_devices) { var existingDevice = FindExistingDeviceNotification(_devices, device.NotificationType, device.Usn); if (existingDevice == null) { _devices.Add(device); isNewDevice = true; } else { _devices.Remove(existingDevice); _devices.Add(device); } } DeviceFound(device, isNewDevice, localIpAddress); return isNewDevice; } ``` Fix is wrap DeviceFound with ``` if (isNewDevice) { DeviceFound(device, isNewDevice, localIpAddress); } ```
OVERLORD added the bug label 2026-02-06 21:37:16 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#2008