Salut,
apology for the delay. This is inside Sebastien tutorial, right?
Parker Lord wrote:
> I have used Sébastien Dionne's three part example on Migrating to
> Grizzly. Thank you Sébastien! The only question I have is in the
> Protocol Parser :
>
> protected static final int LIMITBB = 5;
>
> .....
>
>
> // but check if the max length is attein
> *if (processingBuffer.capacity() + processingBuffer.remaining() < LIMITBB)*
> {
> ByteBuffer newBB = ByteBufferFactory.allocateView(processingBuffer.capacity() * 2, processingBuffer.isDirect());
> newBB.put(processingBuffer);
> processingBuffer = newBB;
> WorkerThread workerThread = (WorkerThread)Thread.currentThread();
> workerThread.setByteBuffer(processingBuffer);
> }
> else
> {
> syslog.severe("BUFFER MAX REACH!");
> processingBuffer.clear();
> maxBufferReached = true;
> return maxBufferReached;
> }
>
> I guess I am missing something in the line that checks to see if we have
> reached our max length.
>
> if (processingBuffer.capacity() + processingBuffer.remaining() < LIMITBB)
>
> is NEVER going to be true. In the initial case where capacity is 8192,
> and the buffer is full, we get this:
>
> if (8192 + 8192 < 5)
>
> Shouldn't this be:
>
> if (processingBuffer.capacity() + processingBuffer.remaining() < (LIMITBB*8192))
I think you are right. Sebastien?
A+
-- Jeanfrancois
>
> or something?
> ------------------------------------------------------------------------
> View this message in context: Question About Protocol Parser Example and
> expanding the Buffer
> <http://www.nabble.com/Question-About-Protocol-Parser-Example-and-expanding-the-Buffer-tp23341414p23341414.html>
> Sent from the Grizzly - Users mailing list archive
> <http://www.nabble.com/Grizzly---Users-f23249.html> at Nabble.com.