Fixing server's alignment of HTTP "chunks" with ICY blocks #718
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Needs more test probably but that fixes the case when streaming server send TCP blocks that are aligned with the 1st byte of ICY metadata. In such case, LMS enters a busy loop inside it's S::P::P::HTTP.pm::sysread and the server might not send the next block before a while. Such busy loop will eat CPU.
With that PR, the readMetaData is made at the beginning of sysread so that, if the previous sysread ended just before the ICY byte, then the current one will start by reading the ICY length (one byte) and if this "fails" (i.e. EWOUDLBLOCK/EAGAIN) then we exit and let the "busy loop" to be handled by the sysread caller (i.e. the event loop) which does not hammer the system, as we would not with a "readChunk"