Skip to content

Conversation

@dbehnke
Copy link
Contributor

@dbehnke dbehnke commented Dec 24, 2025

Walkthrough - Runaway CPU and Blocking Fixes

Resolves #15

I have implemented fixes to address high CPU usage and hanging behavior related to transcoder (tcd) connections.

Changes Made

Transcoder Socket Handling (TCSocket.cpp)

  • Fixed Runaway CPU: Added a sleep delay in CTCServer::Receive that is triggered when a transcoder module is not connected. This prevents CCodecStream threads from spinning in a tight high-frequency loop when tcd is unreachable.
  • Fixed Blocking Behavior: Modified CTCServer::Accept to be non-blocking. It now uses poll with a 100ms timeout on the listening socket. If no connections are pending, it returns immediately instead of waiting indefinitely. This ensures the main MaintenanceThread can continue updating the dashboard even if some transcoder modules are disconnected.

Verification Results

Build Verification

I verified that the code compiles successfully by running a build inside the urfd-runner Docker container.

# Compilation successfully completed inside docker container
docker exec urfd-runner make -C reflector

Note

During verification, I temporarily disabled DHT and strict -Werror flags to accommodate the testing environment. These were fully reverted after the build was confirmed.

How to Verify

  1. Start urfd with transcoder modules configured but without tcd running.
  2. Verify that CPU usage remains low (no runaway urfd process).
  3. Verify that the dashboard (XML/JSON files) continues to update.
  4. Start tcd and verify that urfd gracefully picks up the connections within a few seconds (next MaintenanceThread cycle).

render_diffs(file:///Users/dbehnke/development/urfd/reflector/TCSocket.cpp)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runaway CPU

1 participant