mina-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject git commit: Applied patch from DIRMINA-785
Date Thu, 11 Sep 2014 17:51:23 GMT
Repository: mina
Updated Branches:
  refs/heads/2.0 f04184d9f -> d3f53778d


Applied patch from DIRMINA-785

Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/d3f53778
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/d3f53778
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/d3f53778

Branch: refs/heads/2.0
Commit: d3f53778d6d79a2611c4492364e3d9992e1b4312
Parents: f04184d
Author: Emmanuel L├ęcharny <elecharny@symas.com>
Authored: Thu Sep 11 19:51:06 2014 +0200
Committer: Emmanuel L├ęcharny <elecharny@symas.com>
Committed: Thu Sep 11 19:51:06 2014 +0200

----------------------------------------------------------------------
 .../core/filterchain/DefaultIoFilterChain.java  | 25 ++++++++++++++++++++
 .../apache/mina/core/filterchain/IoFilter.java  |  4 ++++
 .../mina/core/filterchain/IoFilterAdapter.java  |  4 ++++
 .../mina/core/filterchain/IoFilterChain.java    | 16 +++++++++----
 .../polling/AbstractPollingIoProcessor.java     |  4 +++-
 .../mina/core/service/AbstractIoConnector.java  |  4 ++++
 .../org/apache/mina/core/service/IoHandler.java |  5 ++++
 .../mina/core/service/IoHandlerAdapter.java     |  4 ++++
 .../multiton/SingleSessionIoHandler.java        |  4 +++-
 .../multiton/SingleSessionIoHandlerAdapter.java |  4 ++++
 .../SingleSessionIoHandlerDelegate.java         |  9 +++++--
 .../executor/ExecutorFilterRegressionTest.java  |  4 ++++
 12 files changed, 79 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/d3f53778/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
b/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
index 87fc8e1..2a5f329 100644
--- a/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
+++ b/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
@@ -599,6 +599,21 @@ public class DefaultIoFilterChain implements IoFilterChain {
         }
     }
 
+    public void fireInputClosed() {
+        Entry head = this.head;
+        callNextInputClosed(head, session);
+    }
+
+    private void callNextInputClosed(Entry entry, IoSession session) {
+        try {
+            IoFilter filter = entry.getFilter();
+            NextFilter nextFilter = entry.getNextFilter();
+            filter.inputClosed(nextFilter, session);
+        } catch (Throwable e) {
+            fireExceptionCaught(e);
+        }
+    }
+
     public void fireFilterWrite(WriteRequest writeRequest) {
         callPreviousFilterWrite(tail, session, writeRequest);
     }
@@ -815,6 +830,11 @@ public class DefaultIoFilterChain implements IoFilterChain {
         }
 
         @Override
+        public void inputClosed(NextFilter nextFilter, IoSession session) throws Exception
{
+            session.getHandler().inputClosed(session);
+        }
+
+        @Override
         public void messageReceived(NextFilter nextFilter, IoSession session, Object message)
throws Exception {
             AbstractIoSession s = (AbstractIoSession) session;
 
@@ -913,6 +933,11 @@ public class DefaultIoFilterChain implements IoFilterChain {
                     callNextExceptionCaught(nextEntry, session, cause);
                 }
 
+                public void inputClosed(IoSession session) {
+                    Entry nextEntry = EntryImpl.this.nextEntry;
+                    callNextInputClosed(nextEntry, session);
+                }
+
                 public void messageReceived(IoSession session, Object message) {
                     Entry nextEntry = EntryImpl.this.nextEntry;
                     callNextMessageReceived(nextEntry, session, message);

http://git-wip-us.apache.org/repos/asf/mina/blob/d3f53778/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilter.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilter.java b/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilter.java
index 28c5188..e04ec38 100644
--- a/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilter.java
+++ b/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilter.java
@@ -172,6 +172,8 @@ public interface IoFilter {
      */
     void exceptionCaught(NextFilter nextFilter, IoSession session, Throwable cause) throws
Exception;
 
+    void inputClosed(NextFilter nextFilter, IoSession session) throws Exception;
+
     /**
      * Filters {@link IoHandler#messageReceived(IoSession,Object)}
      * event.
@@ -223,6 +225,8 @@ public interface IoFilter {
          */
         void exceptionCaught(IoSession session, Throwable cause);
 
+        void inputClosed(IoSession session);
+
         /**
          * Forwards <tt>messageReceived</tt> event to next filter.
          */

http://git-wip-us.apache.org/repos/asf/mina/blob/d3f53778/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilterAdapter.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilterAdapter.java
b/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilterAdapter.java
index ab9a4ad..39c5508 100644
--- a/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilterAdapter.java
+++ b/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilterAdapter.java
@@ -130,6 +130,10 @@ public class IoFilterAdapter implements IoFilter {
         nextFilter.filterClose(session);
     }
 
+    public void inputClosed(NextFilter nextFilter, IoSession session) throws Exception {
+        nextFilter.inputClosed(session);
+    }
+
     public String toString() {
         return this.getClass().getSimpleName();
     }

http://git-wip-us.apache.org/repos/asf/mina/blob/d3f53778/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilterChain.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilterChain.java b/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilterChain.java
index 8e34bde..ab85eb5 100644
--- a/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilterChain.java
+++ b/mina-core/src/main/java/org/apache/mina/core/filterchain/IoFilterChain.java
@@ -301,11 +301,19 @@ public interface IoFilterChain {
     public void fireExceptionCaught(Throwable cause);
 
     /**
-     * Fires a {@link IoSession#write(Object)} event. Most users don't need to call this
-     * method at all. Please use this method only when you implement a new transport or fire
a
-     * virtual event.
+     * Fires a {@link IoHandler#inputClosed(IoSession, Throwable)} event. Most
+     * users don't need to call this method at all. Please use this method only
+     * when you implement a new transport or fire a virtual event.
+     */
+    public void fireInputClosed();
+
+    /**
+     * Fires a {@link IoSession#write(Object)} event. Most users don't need to
+     * call this method at all. Please use this method only when you implement a
+     * new transport or fire a virtual event.
      * 
-     * @param writeRequest The message to write
+     * @param writeRequest
+     *            The message to write
      */
     public void fireFilterWrite(WriteRequest writeRequest);
 

http://git-wip-us.apache.org/repos/asf/mina/blob/d3f53778/mina-core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
----------------------------------------------------------------------
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 bead516..65ef32a 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
@@ -720,7 +720,9 @@ public abstract class AbstractPollingIoProcessor<S extends AbstractIoSession>
im
             }
 
             if (ret < 0) {
-                scheduleRemove(session);
+                // scheduleRemove(session);
+                IoFilterChain filterChain = session.getFilterChain();
+                filterChain.fireInputClosed();
             }
         } catch (Exception e) {
             if (e instanceof IOException) {

http://git-wip-us.apache.org/repos/asf/mina/blob/d3f53778/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java
b/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java
index c67bc94..ffc11d5 100644
--- a/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java
+++ b/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java
@@ -257,6 +257,10 @@ public abstract class AbstractIoConnector extends AbstractIoService implements
I
                     public void sessionOpened(IoSession session) throws Exception {
                         // Empty handler
                     }
+
+                    public void inputClosed(IoSession session) throws Exception {
+                        // Empty handler
+                    }
                 });
             } else {
                 throw new IllegalStateException("handler is not set.");

http://git-wip-us.apache.org/repos/asf/mina/blob/d3f53778/mina-core/src/main/java/org/apache/mina/core/service/IoHandler.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/service/IoHandler.java b/mina-core/src/main/java/org/apache/mina/core/service/IoHandler.java
index 38bb6c4..4840a9e 100644
--- a/mina-core/src/main/java/org/apache/mina/core/service/IoHandler.java
+++ b/mina-core/src/main/java/org/apache/mina/core/service/IoHandler.java
@@ -78,4 +78,9 @@ public interface IoHandler {
      * sent out.
      */
     void messageSent(IoSession session, Object message) throws Exception;
+
+    /**
+     * Handle the closure of an half-duplex TCP channel
+     */
+    void inputClosed(IoSession session) throws Exception;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina/blob/d3f53778/mina-core/src/main/java/org/apache/mina/core/service/IoHandlerAdapter.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/core/service/IoHandlerAdapter.java b/mina-core/src/main/java/org/apache/mina/core/service/IoHandlerAdapter.java
index d659247..af92c33 100644
--- a/mina-core/src/main/java/org/apache/mina/core/service/IoHandlerAdapter.java
+++ b/mina-core/src/main/java/org/apache/mina/core/service/IoHandlerAdapter.java
@@ -64,4 +64,8 @@ public class IoHandlerAdapter implements IoHandler {
     public void messageSent(IoSession session, Object message) throws Exception {
         // Empty handler
     }
+
+    public void inputClosed(IoSession session) throws Exception {
+        session.close(true);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina/blob/d3f53778/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandler.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandler.java
b/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandler.java
index 6db7645..f180133 100644
--- a/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandler.java
+++ b/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandler.java
@@ -38,7 +38,7 @@ import org.apache.mina.core.session.IoSession;
  * conversational state as instance variables in this object.
  * </p>
  *
- * WARNING: This class is badly named as the actual {@link IoHandler} implementor 
+ * WARNING: This class is badly named as the actual {@link IoHandler} implementor
  * is in fact the {@link SingleSessionIoHandlerDelegate}.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
@@ -90,6 +90,8 @@ public interface SingleSessionIoHandler {
      */
     void exceptionCaught(Throwable cause) throws Exception;
 
+    void inputClosed(IoSession session);
+
     /**
      * Invoked when protocol message is received. Implement your protocol flow
      * here.

http://git-wip-us.apache.org/repos/asf/mina/blob/d3f53778/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerAdapter.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerAdapter.java
b/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerAdapter.java
index 181f6f3..a7ce9e2 100644
--- a/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerAdapter.java
+++ b/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerAdapter.java
@@ -62,6 +62,10 @@ public class SingleSessionIoHandlerAdapter implements SingleSessionIoHandler
{
         // Do nothing
     }
 
+    public void inputClosed(IoSession session) {
+        // Do nothing
+    }
+
     public void messageReceived(Object message) throws Exception {
         // Do nothing
     }

http://git-wip-us.apache.org/repos/asf/mina/blob/d3f53778/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerDelegate.java
----------------------------------------------------------------------
diff --git a/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerDelegate.java
b/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerDelegate.java
index 92f2e8b..f2bd86d 100644
--- a/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerDelegate.java
+++ b/mina-core/src/main/java/org/apache/mina/handler/multiton/SingleSessionIoHandlerDelegate.java
@@ -30,8 +30,8 @@ import org.apache.mina.core.session.IoSession;
  * is used to create a new {@link SingleSessionIoHandler} for each newly
  * created session.
  *
- * WARNING : This {@link IoHandler} implementation may be easier to understand and 
- * thus to use but the user should be aware that creating one handler by session 
+ * WARNING : This {@link IoHandler} implementation may be easier to understand and
+ * thus to use but the user should be aware that creating one handler by session
  * will lower scalability if building an high performance server. This should only
  * be used with very specific needs in mind.
  * 
@@ -145,4 +145,9 @@ public class SingleSessionIoHandlerDelegate implements IoHandler {
         SingleSessionIoHandler handler = (SingleSessionIoHandler) session.getAttribute(HANDLER);
         handler.messageSent(message);
     }
+
+    public void inputClosed(IoSession session) throws Exception {
+        SingleSessionIoHandler handler = (SingleSessionIoHandler) session.getAttribute(HANDLER);
+        handler.inputClosed(session);
+    }
 }

http://git-wip-us.apache.org/repos/asf/mina/blob/d3f53778/mina-core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java
----------------------------------------------------------------------
diff --git a/mina-core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java
b/mina-core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java
index 07b6b6a..2b8aeda 100644
--- a/mina-core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java
+++ b/mina-core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java
@@ -134,6 +134,10 @@ public class ExecutorFilterRegressionTest {
             // Do nothing
         }
 
+        public void inputClosed(IoSession session) {
+            // Do nothing
+        }
+
         public void messageReceived(IoSession session, Object message) {
             try {
                 ((EventOrderCounter) session).setLastCount((Integer) message);


Mime
View raw message