[ 
https://issues.apache.org/jira/browse/DIRMINA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16195839#comment-16195839
 ] 

Jonathan Valliere commented on DIRMINA-1057:
--------------------------------------------

Okay, looks like I found a condition where fireMessageSent can occur more than 
once per WriteRequest causing the counter to go negative.


{code:java}
                int localWrittenBytes = send(session, buf, destination);

                if ((localWrittenBytes == 0) || (writtenBytes >= 
maxWrittenBytes)) {
                    // Kernel buffer is full or wrote too much
                    setInterestedInWrite(session, true);

                    session.getWriteRequestQueue().offer(session, writeRequest);
                    scheduleFlush(session);
                } else {
                    setInterestedInWrite(session, false);

                    // Clear and fire event
                    session.setCurrentWriteRequest(null);
                    writtenBytes += localWrittenBytes;
                    buf.reset();
                    session.getFilterChain().fireMessageSent(writeRequest);

                    break;
                }
{code}

It checks the condition {{((localWrittenBytes == 0) || (writtenBytes >= 
maxWrittenBytes))}} which is incorrect.  It should be {{((localWrittenBytes == 
0) || buf.hasRemaining() || (writtenBytes >= maxWrittenBytes))}}



> AbstractIoSession getScheduledWriteMessages always -negative?
> -------------------------------------------------------------
>
>                 Key: DIRMINA-1057
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-1057
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.16
>         Environment: I'm testing slow consumer backlog detection and while 
> getScheduledWriteBytes() correctly grows, getScheduledWriteMessages is always 
> negative and does not increase. looking into code to see why but putting bug 
> report here as well for tracking
>            Reporter: Andre Mermegas
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to