ChannelStream#readpartial does sub-optimal reads when no bytes buffered
-----------------------------------------------------------------------

                 Key: JRUBY-3666
                 URL: http://jira.codehaus.org/browse/JRUBY-3666
             Project: JRuby
          Issue Type: Improvement
            Reporter: Wayne Meissner
            Assignee: Thomas E Enebo
            Priority: Minor
             Fix For: JRuby 1.4



In the case where a socket is opened, and only readpartial operations are used 
on it, or the buffers are flushed, ChannelStream#readpartial will only ever do 
unbuffered reads.

i.e. if the read buffer is empty when readpartial() is called, it does not 
refill it, and then copy from the buffer to the dst buffer, it just reads 
directly from the channel to the dst buffer.

The offending bit of code:
{code}
if (buffer.hasRemaining()) {
            // already have some bytes buffered, just return those

            ByteList result = bufferedRead(Math.min(buffer.remaining(), 
number));

            if (ungotc >= 0) {
                result.prepend((byte)ungotc);
                ungotc = -1;
            }
            return result;
        } else {
            // otherwise, we try an unbuffered read to get whatever's available
            return read(number);
        }    
{code}

Thats been there for many versions, so its not exactly an urgent fix.



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to