Skip to content

Fix hang when using AbstractClassicEntityProducer#47

Closed
carterkozak wants to merge 1 commit intoapache:masterfrom
carterkozak:classic_entity_producer_hang
Closed

Fix hang when using AbstractClassicEntityProducer#47
carterkozak wants to merge 1 commit intoapache:masterfrom
carterkozak:classic_entity_producer_hang

Conversation

@carterkozak
Copy link
Copy Markdown
Contributor

When AsyncDataProducer.available returns zero, the caller may
not execute the produce method again until
DataStreamChannel.requestOutput has been invoked.

This approach sets available to Integer.MAX_VALUE to avoid this
case. It would be more efficient to call requestOutput after
writes, but I'm not certain if invoking the method unnecessarily
would affect performance, and the MAX_VALUE approach is used by
other producers.

I was able to reproduce this issue in a test by sending a dummy 4gb
stream using AbstractClassicEntityProducer. Overriding available with
a non-zero value stopped the hangs.
Again, it may be more efficient to track available() invocations and
call requestOutput() from a subtype of ContentOutputStream, but I
haven't dug in quite that far yet :-)

When AsyncDataProducer.available returns zero, the caller may
not execute the produce method again until
DataStreamChannel.requestOutput has been invoked.

This approach sets available to Integer.MAX_VALUE to avoid this
case. It would be more efficient to call requestOutput after
writes, but I'm not certain if invoking the method unnecessarily
would affect performance, and the MAX_VALUE approach is used by
other producers.
@ok2c
Copy link
Copy Markdown
Member

ok2c commented Aug 10, 2017

@cakofony Always returning Integer.MAX_VALUE from AsyncDataProducer#available does not sound right me. Simple producers do that if they are self-contained and can always produce more data if the underlying channel is ready. This is not the case with complex producers such as AsyncDataProducer that may not always have data to write to the channel. By returning Integer.MAX_VALUE from AsyncDataProducer#available one can cause the I/O reactor spin busily and produce no data.

We need to think of a better fix. How reliably can you reproduce the issue and would it be possible to make a junit?

@ok2c
Copy link
Copy Markdown
Member

ok2c commented Aug 20, 2017

@cakofony Did you have any luck reproducing the issue with an unit / integration test?

@carterkozak
Copy link
Copy Markdown
Contributor Author

Apologies, I've been busy, I will take a crack at it this week!

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.

2 participants