You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Asankha C. Perera" <as...@apache.org> on 2010/03/05 13:15:32 UTC

Detecting EOF of a Channel when file channels are used [for the IdentityDecoder]

Hi All

I seem to have found a possible bug in the IdentityDecoder which checks
for "this.channel.isOpen()" to detect the EOF when using file channels.
However, it seems like although the remote party does close its side of
the socket, that we will not see it unless we read from the channel, as
the "dst.transferFrom(this.channel, position, count)" only returns 0 or
the number of bytes read - and not -1. The attached fix would use the
session input buffer to attempt a read after a zero byte read - and
hopefully will not cause an issue if its a false alarm and there was
data read into the buffer.

If this is indeed a bug, and the attached is a proper fix, I will commit
it to the code with a JIRA

thanks
asankha

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

http://esbmagic.blogspot.com





Re: Detecting EOF of a Channel when file channels are used [for the IdentityDecoder]

Posted by Oleg Kalnichevski <ol...@apache.org>.
Asankha C. Perera wrote:
> Hi All
> 
> I seem to have found a possible bug in the IdentityDecoder which checks
> for "this.channel.isOpen()" to detect the EOF when using file channels.
> However, it seems like although the remote party does close its side of
> the socket, that we will not see it unless we read from the channel, as
> the "dst.transferFrom(this.channel, position, count)" only returns 0 or
> the number of bytes read - and not -1. The attached fix would use the
> session input buffer to attempt a read after a zero byte read - and
> hopefully will not cause an issue if its a false alarm and there was
> data read into the buffer.
> 
> If this is indeed a bug, and the attached is a proper fix, I will commit
> it to the code with a JIRA
> 
> thanks
> asankha
> 
> 

Hi Asankha

This certainly sounds reasonable. Please go ahead and apply the patch.

Oleg

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