Skip to content

Commit

Permalink
#39 The HTTPS Stream will no longer rely on InputStream.available() a…
Browse files Browse the repository at this point in the history
…s a condition to keep reading data.
  • Loading branch information
hrosa committed Oct 19, 2015
1 parent 0087dff commit 3e481a6
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private void getFormat(InputStream stream) throws IOException {
private int readPacket(byte[] packet, int offset, int psize) throws IOException {
int length = 0;
try {
while (length < psize && inStream.available()>0) {
while (length < psize) {
int len = inStream.read(packet, offset + length, psize - length);
if (len == -1) {
return length;
Expand Down

2 comments on commit 3e481a6

@slhayden
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this fix does bypass the current problem, without a "will it block" check, I think this has the potential to cause all the readers to block at this point (under high load) and bring the entire MMS to a stop since all threads are preallocated and shared within a scheduler loop. It might be best to instead return -1 (instead of 0 indicating EOF) and handle the -1 as a special case of "nothing to read right now" in the process() method of WavTrackImpl.java

@hrosa
Copy link
Contributor Author

@hrosa hrosa commented on 3e481a6 Oct 21, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi slhayden,

I do agree with potential for locking here. When time allows, I will migrate this class to NIO.
Would you like to contribute with a fix for this issue?

Regards

Please sign in to comment.