hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Asankha C. Perera" <asan...@apache.org>
Subject Re: Truncated content-length delimited message bodies with sendfile
Date Wed, 27 Feb 2013 05:33:27 GMT
Hi Oleg
> The behavior of Channel#isOpen() is correct. A channel can be open
> locally (or half-closed) even if it ha been closed by the remote peer.
> As long as the channel is half-closed it should return -1 on all read
> operations instead of throwing an I/O error.
Yes, I see.. it would have been great if FileChannel.transferFrom() 
returned -1 as well, without hiding that underneath the JDK layer, when 
actually encountered
> The problem is this utterly crazy implementation of FileChannelImpl
>
> http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/sun/nio/ch/FileChannelImpl.java#607
>    
> I do not see a reasonable way of working around this insanity. The only
> thing we can do is to plea to Oracle to fix it and pray they would
> heed.
What if we make our LengthDelimitedEncoder try to read into the session 
buffer, if bytes read is found to be zero? This may not be optimal, but 
at least, results in the correct operation.

                 bytesRead = dst.transferFrom(this.channel, position, 
count);
                 if (bytesRead == 0) {
                     bytesRead = this.buffer.fill(this.channel);
                 }

regards
asankha

-- 
Asankha C. Perera
AdroitLogic, http://adroitlogic.org

http://esbmagic.blogspot.com




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message