[ https://issues.apache.org/jira/browse/DIRMINA-1039?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15428260#comment-15428260 ]
Emmanuel Lecharny commented on DIRMINA-1039: -------------------------------------------- Yep, you are right, there is a missing negation :/ Now, I'm coming with a different patch that uses a static {{WriteRequest}} instance instead of creating an empty message : {noformat} diff --git a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java index 5d23b35..c1295f6 100644 --- a/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java +++ b/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java @@ -814,9 +814,6 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im + (session.getConfig().getMaxReadBufferSize() >>> 1); int writtenBytes = 0; WriteRequest req = null; - - // boolean to indicate if the current message is an empty buffer, representing a message marker - boolean isEmptyMessage = false; try { // Clear OP_WRITE @@ -840,7 +837,6 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im Object message = req.getMessage(); if (message instanceof IoBuffer) { - isEmptyMessage = !((IoBuffer) message).hasRemaining(); localWrittenBytes = writeBuffer(session, req, hasFragmentation, maxWrittenBytes - writtenBytes, currentTime); @@ -870,14 +866,11 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession> im } if (localWrittenBytes == 0) { - if (isEmptyMessage) { - // Kernel buffer is full. + + // Kernel buffer is full. + if (!req.equals(AbstractIoSession.MESSAGE_SENT_REQUEST)) { setInterestedInWrite(session, true); return false; - } else { - // Just processed a message marker - empty buffer; - // set the session write flag and continue - setInterestedInWrite(session, true); } } else { writtenBytes += localWrittenBytes; {noformat} > Response messages queue up on the server side waiting to be written to > socket, while the server continues to read more request messages, causing out > of heap memory > ------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > Key: DIRMINA-1039 > URL: https://issues.apache.org/jira/browse/DIRMINA-1039 > Project: MINA > Issue Type: Bug > Components: Core > Reporter: Maria Petridean > Fix For: 2.0.14 > > > One case in which this bug reproduces is by using a client which generates a > heavy request-load. The mina thread which processes both reads and writes - > exits the write cycle after processing every empty marker (the WriteRequest > which wraps an empty buffer, acting as a message marker). This will result in > the thread resuming the read cycle, hence reading more client request > messages. After a few minutes, the number of read messages is much larger > than the number of written response messages, even though the responses are > waiting in the queue, ready to be written to socket. > To solve this, the sever shouldn't exit the write cycle after processing > every marker WriteRequest. This way the ratio between the read and written > messages will be more balanced; this will avoid the heap memory getting full > and causing server degradation. > Also, an improvement can be considered here to avoid using the same single > thread for both reads and writes. -- This message was sent by Atlassian JIRA (v6.3.4#6332)