cweld510 commented on pull request #224:
URL: 
https://github.com/apache/httpcomponents-core/pull/224#issuecomment-699559951


   @ok2c 
   
   You're right that calling this a deadlock is a misnomer. I can change my 
description.
   
   In response to your second question: when the race condition occurs, the 
thread that calls requestOutput from the SharedOutputBuffer doesn't write to 
the output buffer owned by that class, e.g. by calling `buffer().put(src)`. 
Instead, it calls `dataStreamChannel.write(src)` on line 98 of 
SharedOutputBuffer, but writes zero bytes. So `final boolean outputPending = 
isOutputReady()` will be false in this circumstance, because `isOutputReady()` 
only checks the buffer owned by SharedOutputBuffer.
   
   To provide more information, I'm attaching a callstack of the thread that 
calls `dataStreamChannel.write(src)` on line 98 of SharedOutputBuffer. (line 
numbers are slightly different in BzSharedOutputBuffer but the `write` method 
is identical.) Hopefully this can show how a thread can signal output readiness 
but `final boolean outputPending = isOutputReady()` and `outbuf.hasData()` will 
both be false. The callstack isn't entirely complete, because i just stepped 
into `dataStreamChannel.write(src)` several layers deep and eventually copied 
it, but it should still outline the write thread's path of execution. Note that 
`SSLIOSession.write()` can return 0 here.
   
   
   
[stacktrace.txt](https://github.com/apache/httpcomponents-core/files/5287463/stacktrace.txt)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to