[PR #899] [MERGED] DLNA: Fix race condition leading to missing device names #8553

Closed
opened 2026-02-07 05:46:26 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/899
Author: @AThomsen
Created: 2/15/2019
Status: Merged
Merged: 2/16/2019
Merged by: @Bond-009

Base: release-10.2.zHead: bugfix/dlna_name_race_condition


📝 Commits (1)

  • 7bb8985 Fix race condition in adding dlna devices to session when the device is discovered repeatedly

📊 Changes

1 file changed (+5 additions, -5 deletions)

View changed files

📝 Emby.Dlna/PlayTo/PlayToManager.cs (+5 -5)

📄 Description

Changes
On device discovery the current code checks if the session contains the discovered device. If it exists, nothing more is done. However, when a device is first discovered, different methods are called to (1) add the device to the session and (2) set the device's name.

This race condition can occur:

  1. Device is discovered (does not exist in sessions).
  2. Device is added/updated (GetOrAdd) with null as name. <-- here it's added for the first time
  3. Name is set. <-- only called if device was not already added
  4. Device is discovered (again) (still does not exist in sessions)
  5. Device is added/updated (GetOrAdd) with null as name. <-- second time. Now it just updates with null as the name
  6. Device added to session.

The code is not that easy to fix so the proposed patch simply moves the "is device already added" check inside the lock.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/899 **Author:** [@AThomsen](https://github.com/AThomsen) **Created:** 2/15/2019 **Status:** ✅ Merged **Merged:** 2/16/2019 **Merged by:** [@Bond-009](https://github.com/Bond-009) **Base:** `release-10.2.z` ← **Head:** `bugfix/dlna_name_race_condition` --- ### 📝 Commits (1) - [`7bb8985`](https://github.com/jellyfin/jellyfin/commit/7bb8985f11569905af4edbf4c47cba4d9b32c7ca) Fix race condition in adding dlna devices to session when the device is discovered repeatedly ### 📊 Changes **1 file changed** (+5 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `Emby.Dlna/PlayTo/PlayToManager.cs` (+5 -5) </details> ### 📄 Description **Changes** On device discovery the current code checks if the session contains the discovered device. If it exists, nothing more is done. However, when a device is first discovered, different methods are called to (1) add the device to the session and (2) set the device's name. This race condition can occur: 1. Device is discovered (does not exist in sessions). 2. Device is added/updated (GetOrAdd) with null as name. <-- here it's added for the first time 3. Name is set. <-- only called if device was not already added 4. Device is discovered (again) (still does not exist in sessions) 5. Device is added/updated (GetOrAdd) with null as name. <-- second time. Now it just updates with null as the name 6. Device added to session. The code is not that easy to fix so the proposed patch simply moves the "is device already added" check inside the lock. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-07 05:46:26 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#8553