Old 14th July 2017, 02:57   #1
Junior Member
Join Date: Jul 2017
Posts: 1
Bug: AutoDumpTime setting of 0 doesn't play well with poll()


I found a bug in ShoutCast. If I should file this somewhere else, just let me know.

The documentation for the config variable AutoDumpTime includes:
"A value of zero means there is no timeout of an idle connection."
The value of AutoDumpTime is used as the timeout argument to the poll() system call when poll()ing the file descriptors associated with network connections (on Linux and macOS; perhaps elsewhere as well?). The problem is that poll() has a different special meaning for zero. The poll() man page says the following about the timeout argument:
"Specifying a negative value in timeout means an infinite time‐out. Specifying a timeout of zero causes poll() to return immediately, even if no file descriptors are ready."
When a ShoutCast service is configured with AutoDumpTime of zero, this can result in high CPU usage because we're basically just exiting and re-entering the poll()ing loop as fast as possible. I caught this in action and did some kernel tracing to come to this conclusion; you may find the details here: https://gist.github.com/dreness/aec4...2951b27d7245f3

Note that the default value for AutoDumpTime is 30 seconds, so this bug would only bite for those who configure it to zero. I think the fix is to special-case the poll()ing code to use a value of -1 for timeout if AutoDumpTime is set to zero, to align with the special case expectations of poll() with those of ShoutCast.

dreness is offline   Reply With Quote
Old 16th July 2017, 17:57   #2
Major Dude
dopelabs's Avatar
Join Date: Oct 2006
Location: Silicon Valley
Posts: 534
Send a message via AIM to dopelabs
I can confirm this. it basically eats up an entire core. everything else functions normally though... I didn't notice any playback or streaming problems outside of the high cpu on a single core....
dopelabs is offline   Reply With Quote
Old 16th July 2017, 19:16   #3
Forum King
djSpinnerCee's Avatar
Join Date: Aug 2004
Location: Hollis, Queens/The Bronx, NYC
Posts: 3,552
then making the AutoDumpTime timeout rediculously large (86400) would have a similar effect without the cpu loading?

add: AutoDumpUsers is also effected by this issue...
djSpinnerCee is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Technical Support

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump