You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Robert Greig (JIRA)" <ji...@apache.org> on 2006/04/04 17:01:47 UTC

[jira] Commented: (DIRMINA-201) Make the CumulativeProtocolDecoder "slice compatible"

    [ http://issues.apache.org/jira/browse/DIRMINA-201?page=comments#action_12373101 ] 

Robert Greig commented on DIRMINA-201:
--------------------------------------

In an attempt to fix this I have modified CumulativeProtocolDecoder and also SocketIoProcessor (attached to this issue).

The change to SocketIoProcessor is not strictly related but is something I noticed when examining this issue. It allocates a buffer, reads data from the network into it, then allocates another buffer before passing the data to the filter chain. I couldn't see why it did the allocation twice so I have removed the second allocation and copy.

The change to the CumulativeProtocolDecoder can be summarised like this:

* do not store and reuse a buffer
* in the case (which is > 90% of the time in my tests) where there is no data left over from a previous decode attempt, simply use the buffer that has been passed in
* where there is data left over, store that in a buffer in the session and next time round append the data from the network to that

Can someone take a look at the changes and see if they can spot any flaws? The CumulativeProtocolDecoder unit tests pass and my application runs fine (haven't done scientific performance benchmarking yet but hope to do so tomorrow).

> Make the CumulativeProtocolDecoder "slice compatible"
> -----------------------------------------------------
>
>          Key: DIRMINA-201
>          URL: http://issues.apache.org/jira/browse/DIRMINA-201
>      Project: Directory MINA
>         Type: Improvement

>     Versions: 0.9.3
>     Reporter: Robert Greig

>
> There is a problem with using slice() along with the CumulativeProtocolDecoder. 
> The problem is that the CPD does a compact() when it has completed the attempt to decode the buffer, and then reuses the buffer.
> If your decoder expects to be able to take a slice() of the buffer and use that it will find the data gets corrupted by the next call to the CumulativeProtocolDecoder.

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