You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by beharder <ss...@126.com> on 2007/11/16 16:41:37 UTC
Is it a bug about the read method of class SocketIoProcessor
Hi all,
In the read method of class SocketIoProcessor:
try {
......
if (readBytes > 0) {
session.getFilterChain().fireMessageReceived(session, buf);
buf = null;
} catch (Throwable e) {
....
} finally {
if (buf != null)
buf.release();
}
In abvoe codes, why the var buf is set to null after notifying all filters?
The buf.release() can't be called if buf is set to null, that means the buf
cann't be put into the buffer pool managed by calss
PooledByteBufferAllocator.
It also leads to the buffer can't be reuse.
Is it a bug, or something behind it I don't know?
Thanks & best regards,
beharder
--
View this message in context: http://www.nabble.com/Is-it-a-bug-about-the-read-method-of-class-SocketIoProcessor-tf4822028s16868.html#a13795481
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: Is it a bug about the read method of class SocketIoProcessor
Posted by Trustin Lee <tr...@gmail.com>.
Hi Beharder,
It's not a bug. The 'buf' should be released only when the read
operation fails (i.e. when an exception is raised) and therefore it is
not set to null. If the read operation succeeds, buf.release() is
called later somewhere in the filter chain or a filer. :)
HTH,
Trustin
On Nov 17, 2007 12:41 AM, beharder <ss...@126.com> wrote:
>
> Hi all,
>
> In the read method of class SocketIoProcessor:
>
> try {
> ......
> if (readBytes > 0) {
> session.getFilterChain().fireMessageReceived(session, buf);
> buf = null;
>
>
> } catch (Throwable e) {
> ....
> } finally {
> if (buf != null)
> buf.release();
> }
>
> In abvoe codes, why the var buf is set to null after notifying all filters?
>
> The buf.release() can't be called if buf is set to null, that means the buf
> cann't be put into the buffer pool managed by calss
> PooledByteBufferAllocator.
>
> It also leads to the buffer can't be reuse.
>
> Is it a bug, or something behind it I don't know?
>
> Thanks & best regards,
> beharder
>
> --
> View this message in context: http://www.nabble.com/Is-it-a-bug-about-the-read-method-of-class-SocketIoProcessor-tf4822028s16868.html#a13795481
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
>
>
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6