Linux allows a thread name of at most 15 characters, and
pthread_setname_np fails with ERANGE for a longer one, but
setCurrentThreadName ignored the result and returned true. Every name
the library sets is longer than that ("avdecc::watchDog" is 16
characters, "avdecc::PCapInterface::Capture" 30), so none took effect:
each thread kept the name it inherited from the thread that created it.
setCurrentThreadName now returns whether the name was set, on macOS and
Linux too, rather than truncating it, and each caller that can run on
Linux falls back to a name short enough for it that still identifies
its thread.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012i5Dd3gCyYqp4X7vxhSmxh
On Linux,
pthread_setname_npfails withERANGEfor a name longer than 15 characters, andsetCurrentThreadNameignores the result and returnstrue. Every name the library sets is longer than that (avdecc::watchDogis 16 characters,avdecc::PCapInterface::Capture30), so none of them take effect: each thread keeps the name it inherited from the thread that created it, which makes the library's threads hard to tell apart intop,perfor a debugger.setCurrentThreadNamenow returns whether the name was set, from the result ofpthread_setname_np(Linux and macOS) orprctl, and no longer truncates.avdecc:watchDog,avdecc:SM,avdecc:ctrlSM,avdecc:pcap,avdecc:serial,avdecc:localandavdecc:virtual. An executor falls back toExec:followed by the first 10 characters of the last::component of its name, which tells executors apart.This overlaps #204 in
src/watchDog.cppandCHANGELOG-avdecc.md, so whichever is merged second needs a small rebase.Testing: builds on
dev, and together with the watchdog and state machine changes in #204 and #205, the unit tests give the same results asdevwithout them: 289 of 292 pass.INTEGRATION_EndStation.DestroyWhileMessageInflight_pcapandINTEGRATION_ProtocolInterfacePCap_F.VuDelegatefail either way, as they need pcap access to a real interface.🤖 Generated with Claude Code
https://claude.ai/code/session_012i5Dd3gCyYqp4X7vxhSmxh