You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tr...@apache.org on 2008/05/14 07:27:24 UTC
svn commit: r656108 -
/mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeFilterChain.java
Author: trustin
Date: Tue May 13 22:27:24 2008
New Revision: 656108
URL: http://svn.apache.org/viewvc?rev=656108&view=rev
Log:
Fixed issue: DIRMINA-578 in tennis example version 1.1.7 is fine but for version 2.0M1, there's a funny output order (all RCVD first and SENT last).
* The root cause of the problem is that VmPipeFilterChain purely relies on method invocation chaining for every messageReceived/Sent event emission. I made messageSent event is queued first and flushed later so the event order is reversed.
Modified:
mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeFilterChain.java
Modified: mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeFilterChain.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeFilterChain.java?rev=656108&r1=656107&r2=656108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeFilterChain.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeFilterChain.java Tue May 13 22:27:24 2008
@@ -62,8 +62,12 @@
}
private void pushEvent(IoEvent e) {
+ pushEvent(e, flushEnabled);
+ }
+
+ private void pushEvent(IoEvent e, boolean flushNow) {
eventQueue.add(e);
- if (flushEnabled) {
+ if (flushNow) {
flushEvents();
}
}
@@ -183,15 +187,18 @@
long currentTime = System.currentTimeMillis();
while ((req = queue.poll(session)) != null) {
Object m = req.getMessage();
+ pushEvent(new IoEvent(IoEventType.MESSAGE_SENT, session, req), false);
session.getRemoteSession().getFilterChain().fireMessageReceived(
getMessageCopy(m));
if (m instanceof IoBuffer) {
session.increaseWrittenBytes0(
((IoBuffer) m).remaining(), currentTime);
}
- session.getFilterChain().fireMessageSent(req);
}
} finally {
+ if (flushEnabled) {
+ flushEvents();
+ }
session.getLock().unlock();
}
@@ -202,7 +209,7 @@
while ((req = queue.poll(session)) != null) {
failedRequests.add(req);
}
-
+
if (!failedRequests.isEmpty()) {
WriteToClosedSessionException cause = new WriteToClosedSessionException(failedRequests);
for (WriteRequest r: failedRequests) {
@@ -240,6 +247,7 @@
}
public void add(VmPipeSessionImpl session) {
+ // Unused
}
public void updateTrafficMask(VmPipeSessionImpl session) {
@@ -252,11 +260,12 @@
}
if (session.getTrafficMask().isWritable()) {
- flush(session); // The second parameter is unused.
+ flush(session);
}
}
public void dispose() {
+ // Nothing to dispose
}
public boolean isDisposed() {