mina-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvermill...@apache.org
Subject svn commit: r713957 [1/2] - in /mina/trunk: core/src/main/java/org/apache/mina/core/filterchain/ core/src/main/java/org/apache/mina/core/future/ core/src/main/java/org/apache/mina/core/polling/ core/src/main/java/org/apache/mina/core/service/ core/src/...
Date Fri, 14 Nov 2008 09:27:24 GMT
Author: jvermillard
Date: Fri Nov 14 01:27:16 2008
New Revision: 713957

URL: http://svn.apache.org/viewvc?rev=713957&view=rev
Log:
merging some code simplification : 
 * Removed IoService idle event, you still have IoSession idle.
 * Reworked IdleStatusChecker for make the code easier to understand.
 * Removed setTrafficMask and keeped suspendWrite / suspendRead methods.
 * Removed trafficMask event from the IoFilter chain.
 * Applied http://issues.apache.org/jira/browse/DIRMINA-620 by
   removing superfluous IoSession close() methods. When you close a
   session, you need to use session.close(boolean); and say explicitly
   if you want to flush the write queue or no.


Removed:
    mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceIdleState.java
    mina/trunk/core/src/main/java/org/apache/mina/core/session/TrafficMask.java
    mina/trunk/integration-beans/src/main/java/org/apache/mina/integration/beans/TrafficMaskEditor.java
Modified:
    mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
    mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilter.java
    mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterAdapter.java
    mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterChain.java
    mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterEvent.java
    mina/trunk/core/src/main/java/org/apache/mina/core/future/CloseFuture.java
    mina/trunk/core/src/main/java/org/apache/mina/core/future/IoFutureListener.java
    mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingConnectionlessIoAcceptor.java
    mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoConnector.java
    mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
    mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java
    mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java
    mina/trunk/core/src/main/java/org/apache/mina/core/service/IoProcessor.java
    mina/trunk/core/src/main/java/org/apache/mina/core/service/IoService.java
    mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java
    mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java
    mina/trunk/core/src/main/java/org/apache/mina/core/service/SimpleIoProcessorPool.java
    mina/trunk/core/src/main/java/org/apache/mina/core/session/AbstractIoSession.java
    mina/trunk/core/src/main/java/org/apache/mina/core/session/DummySession.java
    mina/trunk/core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java
    mina/trunk/core/src/main/java/org/apache/mina/core/session/IdleStatusChecker.java
    mina/trunk/core/src/main/java/org/apache/mina/core/session/IoEvent.java
    mina/trunk/core/src/main/java/org/apache/mina/core/session/IoEventType.java
    mina/trunk/core/src/main/java/org/apache/mina/core/session/IoSession.java
    mina/trunk/core/src/main/java/org/apache/mina/filter/firewall/BlacklistFilter.java
    mina/trunk/core/src/main/java/org/apache/mina/filter/firewall/ConnectionThrottleFilter.java
    mina/trunk/core/src/main/java/org/apache/mina/filter/keepalive/KeepAliveRequestTimeoutHandler.java
    mina/trunk/core/src/main/java/org/apache/mina/filter/util/ReferenceCountingFilter.java
    mina/trunk/core/src/main/java/org/apache/mina/handler/demux/ExceptionHandler.java
    mina/trunk/core/src/main/java/org/apache/mina/handler/stream/IoSessionOutputStream.java
    mina/trunk/core/src/main/java/org/apache/mina/handler/stream/StreamIoHandler.java
    mina/trunk/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java
    mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
    mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
    mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeFilterChain.java
    mina/trunk/core/src/test/java/org/apache/mina/filter/buffer/BufferedWriteFilterTest.java
    mina/trunk/core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java
    mina/trunk/core/src/test/java/org/apache/mina/filter/logging/MdcInjectionFilterTest.java
    mina/trunk/core/src/test/java/org/apache/mina/filter/stream/AbstractStreamWriteFilterTest.java
    mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractBindTest.java
    mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractConnectorTest.java
    mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractFileRegionTest.java
    mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractTrafficControlTest.java
    mina/trunk/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramConfigTest.java
    mina/trunk/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramRecyclerTest.java
    mina/trunk/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeEventOrderTest.java
    mina/trunk/example/src/main/java/org/apache/mina/example/chat/ChatProtocolHandler.java
    mina/trunk/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java
    mina/trunk/example/src/main/java/org/apache/mina/example/echoserver/EchoProtocolHandler.java
    mina/trunk/example/src/main/java/org/apache/mina/example/gettingstarted/timeserver/TimeServerHandler.java
    mina/trunk/example/src/main/java/org/apache/mina/example/imagine/step1/client/ImageClient.java
    mina/trunk/example/src/main/java/org/apache/mina/example/netcat/NetCatProtocolHandler.java
    mina/trunk/example/src/main/java/org/apache/mina/example/proxy/AbstractProxyIoHandler.java
    mina/trunk/example/src/main/java/org/apache/mina/example/proxy/ClientToProxyIoHandler.java
    mina/trunk/example/src/main/java/org/apache/mina/example/reverser/ReverseProtocolHandler.java
    mina/trunk/example/src/main/java/org/apache/mina/example/sumup/ClientSessionHandler.java
    mina/trunk/example/src/main/java/org/apache/mina/example/sumup/ServerSessionHandler.java
    mina/trunk/example/src/main/java/org/apache/mina/example/tapedeck/AuthenticationHandler.java
    mina/trunk/example/src/main/java/org/apache/mina/example/tapedeck/TapeDeckServer.java
    mina/trunk/example/src/main/java/org/apache/mina/example/tennis/TennisPlayer.java
    mina/trunk/example/src/main/java/org/apache/mina/example/udp/MemoryMonitorHandler.java
    mina/trunk/example/src/test/java/org/apache/mina/example/echoserver/ConnectorTest.java
    mina/trunk/example/src/test/java/org/apache/mina/example/echoserver/ssl/SslFilterTest.java
    mina/trunk/example/src/test/java/org/apache/mina/example/proxy/ClientSessionHandler.java
    mina/trunk/example/src/test/java/org/apache/mina/example/proxy/telnet/TelnetSessionHandler.java
    mina/trunk/integration-xbean/src/main/java/org/apache/mina/integration/xbean/MinaPropertyEditorRegistrar.java
    mina/trunk/transport-serial/src/main/java/org/apache/mina/transport/serial/SerialConnector.java
    mina/trunk/transport-serial/src/main/java/org/apache/mina/transport/serial/SerialSessionImpl.java

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java Fri Nov 14 01:27:16 2008
@@ -33,7 +33,6 @@
 import org.apache.mina.core.session.AttributeKey;
 import org.apache.mina.core.session.IdleStatus;
 import org.apache.mina.core.session.IoSession;
-import org.apache.mina.core.session.TrafficMask;
 import org.apache.mina.core.write.WriteRequest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -489,7 +488,7 @@
         } else {
             // Please note that this place is not the only place that
             // calls ConnectFuture.setException().
-            session.close();
+            session.close(true);
             future.setException(cause);
         }
     }
@@ -526,23 +525,6 @@
         }
     }
 
-    public void fireFilterSetTrafficMask(TrafficMask trafficMask) {
-        Entry tail = this.tail;
-        callPreviousFilterSetTrafficMask(tail, session, trafficMask);
-    }
-
-    private void callPreviousFilterSetTrafficMask(Entry entry,
-            IoSession session, TrafficMask trafficMask) {
-        try {
-            IoFilter filter = entry.getFilter();
-            NextFilter nextFilter = entry.getNextFilter();
-            filter.filterSetTrafficMask(nextFilter,
-                    session, trafficMask);
-        } catch (Throwable e) {
-            fireExceptionCaught(e);
-        }
-    }
-
     public List<Entry> getAll() {
         List<Entry> list = new ArrayList<Entry>();
         EntryImpl e = head.nextEntry;
@@ -646,7 +628,7 @@
             }
 
             s.getWriteRequestQueue().offer(s, writeRequest);
-            if (s.getTrafficMask().isWritable()) {
+            if (!s.isWriteSuspended()) {
                 s.getProcessor().flush(s);
             }
         }
@@ -655,18 +637,8 @@
         @Override
         public void filterClose(NextFilter nextFilter, IoSession session)
                 throws Exception {
-            ((AbstractIoSession) session).getProcessor().remove(session);
-        }
-
-        @SuppressWarnings("unchecked")
-        @Override
-        public void filterSetTrafficMask(NextFilter nextFilter,
-                IoSession session, TrafficMask trafficMask) throws Exception {
-            AbstractIoSession s = (AbstractIoSession) session;
-            s.setTrafficMaskNow(trafficMask);
-            s.getProcessor().updateTrafficMask(s);
+            ((AbstractIoSession) session).getProcessor().remove(((AbstractIoSession) session));
         }
-
     }
 
     private static class TailFilter extends IoFilterAdapter {
@@ -846,13 +818,6 @@
                     Entry nextEntry = EntryImpl.this.prevEntry;
                     callPreviousFilterClose(nextEntry, session);
                 }
-
-                public void filterSetTrafficMask(IoSession session,
-                        TrafficMask trafficMask) {
-                    Entry nextEntry = EntryImpl.this.prevEntry;
-                    callPreviousFilterSetTrafficMask(nextEntry, session,
-                            trafficMask);
-                }
                 
                 public String toString() {
                 	return EntryImpl.this.nextEntry.name;

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilter.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilter.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilter.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilter.java Fri Nov 14 01:27:16 2008
@@ -22,7 +22,6 @@
 import org.apache.mina.core.service.IoHandler;
 import org.apache.mina.core.session.IdleStatus;
 import org.apache.mina.core.session.IoSession;
-import org.apache.mina.core.session.TrafficMask;
 import org.apache.mina.core.write.WriteRequest;
 import org.apache.mina.filter.util.ReferenceCountingFilter;
 
@@ -209,12 +208,6 @@
             WriteRequest writeRequest) throws Exception;
     
     /**
-     * Filters {@link IoSession#setTrafficMask(TrafficMask)} method invocation.
-     */
-    void filterSetTrafficMask(
-            NextFilter nextFilter, IoSession session, TrafficMask trafficMask) throws Exception;
-
-    /**
      * Represents the next {@link IoFilter} in {@link IoFilterChain}.
      */
     public interface NextFilter {
@@ -263,9 +256,5 @@
          */
         void filterClose(IoSession session);
         
-        /**
-         * Forwards <tt>filterSetTrafficMask</tt> event to next filter.
-         */
-        void filterSetTrafficMask(IoSession session, TrafficMask trafficMask);
     }
 }

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterAdapter.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterAdapter.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterAdapter.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterAdapter.java Fri Nov 14 01:27:16 2008
@@ -21,7 +21,6 @@
 
 import org.apache.mina.core.session.IdleStatus;
 import org.apache.mina.core.session.IoSession;
-import org.apache.mina.core.session.TrafficMask;
 import org.apache.mina.core.write.WriteRequest;
 
 /**
@@ -144,14 +143,6 @@
             throws Exception {
         nextFilter.filterClose(session);
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void filterSetTrafficMask(NextFilter nextFilter, IoSession session,
-            TrafficMask trafficMask) throws Exception {
-        nextFilter.filterSetTrafficMask(session, trafficMask);
-    }
     
     public String toString() {
     	return this.getClass().getSimpleName();

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterChain.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterChain.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterChain.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterChain.java Fri Nov 14 01:27:16 2008
@@ -25,7 +25,6 @@
 import org.apache.mina.core.service.IoHandler;
 import org.apache.mina.core.session.IdleStatus;
 import org.apache.mina.core.session.IoSession;
-import org.apache.mina.core.session.TrafficMask;
 import org.apache.mina.core.write.WriteRequest;
 
 /**
@@ -281,13 +280,6 @@
     public void fireFilterClose();
 
     /**
-     * Fires a {@link IoSession#setTrafficMask(TrafficMask)} 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 fireFilterSetTrafficMask(TrafficMask trafficMask);
-
-    /**
      * Represents a name-filter pair that an {@link IoFilterChain} contains.
      *
      * @author The Apache MINA Project (dev@mina.apache.org)

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterEvent.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterEvent.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterEvent.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/filterchain/IoFilterEvent.java Fri Nov 14 01:27:16 2008
@@ -24,7 +24,6 @@
 import org.apache.mina.core.session.IoEvent;
 import org.apache.mina.core.session.IoEventType;
 import org.apache.mina.core.session.IoSession;
-import org.apache.mina.core.session.TrafficMask;
 import org.apache.mina.core.write.WriteRequest;
 
 /**
@@ -65,9 +64,6 @@
         case WRITE:
             getNextFilter().filterWrite(getSession(), (WriteRequest) getParameter());
             break;
-        case SET_TRAFFIC_MASK:
-            getNextFilter().filterSetTrafficMask(getSession(), (TrafficMask) getParameter());
-            break;
         case CLOSE:
             getNextFilter().filterClose(getSession());
             break;

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/future/CloseFuture.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/future/CloseFuture.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/future/CloseFuture.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/future/CloseFuture.java Fri Nov 14 01:27:16 2008
@@ -26,7 +26,7 @@
  * <h3>Example</h3>
  * <pre>
  * IoSession session = ...;
- * CloseFuture future = session.close();
+ * CloseFuture future = session.close(true);
  * // Wait until the connection is closed
  * future.awaitUninterruptibly();
  * // Now connection should be closed.

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/future/IoFutureListener.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/future/IoFutureListener.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/future/IoFutureListener.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/future/IoFutureListener.java Fri Nov 14 01:27:16 2008
@@ -37,7 +37,7 @@
      */
     static IoFutureListener<IoFuture> CLOSE = new IoFutureListener<IoFuture>() {
         public void operationComplete(IoFuture future) {
-            future.getSession().close();
+            future.getSession().close(true);
         }
     };
 

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingConnectionlessIoAcceptor.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingConnectionlessIoAcceptor.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingConnectionlessIoAcceptor.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingConnectionlessIoAcceptor.java Fri Nov 14 01:27:16 2008
@@ -39,7 +39,6 @@
 import org.apache.mina.core.service.IoProcessor;
 import org.apache.mina.core.session.AbstractIoSession;
 import org.apache.mina.core.session.ExpiringSessionRecycler;
-import org.apache.mina.core.session.IdleStatusChecker;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.core.session.IoSessionConfig;
 import org.apache.mina.core.session.IoSessionRecycler;
@@ -282,7 +281,7 @@
             getListeners().fireSessionDestroyed(session);
         }
 
-        public void updateTrafficMask(T session) {
+        public void updateTrafficControl(T session) {
             throw new UnsupportedOperationException();
         }
 
@@ -571,7 +570,7 @@
         // process idle sessions
         if (currentTime - lastIdleCheckTime >= 1000) {
             lastIdleCheckTime = currentTime;
-            IdleStatusChecker.notifyIdleness(
+            AbstractIoSession.notifyIdleness(
                     getListeners().getManagedSessions().values().iterator(),
                     currentTime);
         }

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoConnector.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoConnector.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoConnector.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoConnector.java Fri Nov 14 01:27:16 2008
@@ -41,6 +41,7 @@
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.core.session.IoSessionConfig;
 import org.apache.mina.core.session.IoSessionInitializer;
+import org.apache.mina.transport.socket.nio.NioSocketConnector;
 import org.apache.mina.util.ExceptionMonitor;
 
 /**

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java Fri Nov 14 01:27:16 2008
@@ -20,7 +20,6 @@
 package org.apache.mina.core.polling;
 
 import java.io.IOException;
-import java.nio.channels.SelectionKey;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -38,7 +37,6 @@
 import org.apache.mina.core.service.AbstractIoService;
 import org.apache.mina.core.service.IoProcessor;
 import org.apache.mina.core.session.AbstractIoSession;
-import org.apache.mina.core.session.IdleStatusChecker;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.core.session.IoSessionConfig;
 import org.apache.mina.core.write.WriteRequest;
@@ -545,11 +543,11 @@
 
     private void process(T session) {
 
-        if (isReadable(session) && session.getTrafficMask().isReadable()) {
+        if (isReadable(session) && !session.isReadSuspended()) {
             read(session);
         }
 
-        if (isWritable(session) && session.getTrafficMask().isWritable()) {
+        if (isWritable(session) && !session.isWriteSuspended()) {
             scheduleFlush(session);
         }
     }
@@ -612,7 +610,7 @@
         // process idle sessions
         if (currentTime - lastIdleCheckTime >= 1000) {
             lastIdleCheckTime = currentTime;
-            IdleStatusChecker.notifyIdleness(allSessions(), currentTime);
+            AbstractIoSession.notifyIdleness(allSessions(), currentTime);
         }
     }
 
@@ -819,7 +817,7 @@
             SessionState state = state(session);
             switch (state) {
             case OPEN:
-                updateTrafficMaskNow(session);
+            	updateTrafficControl(session);
                 break;
             case CLOSED:
                 break;
@@ -835,12 +833,9 @@
         }
     }
 
-    private void updateTrafficMaskNow(T session) {
-        // The normal is OP_READ and, if there are write requests in the
-        // session's write queue, set OP_WRITE to trigger flushing.
-        int mask = session.getTrafficMask().getInterestOps();
-        try {
-            setInterestedInRead(session, (mask & SelectionKey.OP_READ) != 0);
+    public void updateTrafficControl(T session) {
+    	try {
+            setInterestedInRead(session, !session.isReadSuspended());
         } catch (Exception e) {
             IoFilterChain filterChain = session.getFilterChain(); 
             filterChain.fireExceptionCaught(e);
@@ -849,14 +844,13 @@
             setInterestedInWrite(
                     session,
                     !session.getWriteRequestQueue().isEmpty(session) &&
-                            (mask & SelectionKey.OP_WRITE) != 0);
+                            !session.isWriteSuspended());
         } catch (Exception e) {
             IoFilterChain filterChain = session.getFilterChain(); 
             filterChain.fireExceptionCaught(e);
         }
     }
-
-    
+        
     private class Processor implements Runnable {
         public void run() {
             int nSessions = 0;

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java Fri Nov 14 01:27:16 2008
@@ -280,7 +280,7 @@
         future.addListener(new IoFutureListener<ConnectFuture>() {
             public void operationComplete(ConnectFuture future) {
                 if (future.isCanceled()) {
-                    session.close();
+                    session.close(true);
                 }
             }
         });

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/service/AbstractIoService.java Fri Nov 14 01:27:16 2008
@@ -41,7 +41,6 @@
 import org.apache.mina.core.session.AbstractIoSession;
 import org.apache.mina.core.session.DefaultIoSessionDataStructureFactory;
 import org.apache.mina.core.session.IdleStatus;
-import org.apache.mina.core.session.IdleStatusChecker;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.core.session.IoSessionConfig;
 import org.apache.mina.core.session.IoSessionDataStructureFactory;
@@ -105,12 +104,9 @@
             _stats.setLastWriteTime(s.getActivationTime());
             _stats.setLastThroughputCalculationTime(s.getActivationTime());
 
-            // Start idleness notification.
-            idleStatusChecker.addService(s);
         }
 
         public void serviceDeactivated(IoService service) {
-            idleStatusChecker.removeService((AbstractIoService) service);
         }
 
         public void serviceIdle(IoService service, IdleStatus idleStatus) {
@@ -147,17 +143,11 @@
 
     private IoFuture disposalFuture;
 
-    private final IdleStatusChecker idleStatusChecker = new IdleStatusChecker();
-
     /**
      * {@inheritDoc}
      */
     private IoServiceStatistics stats = new IoServiceStatistics(this);
     
-    /**
-     * Reference to the object holding all the idle state vars.
-     */    
-    private IoServiceIdleState idleState = new IoServiceIdleState(this);
 
     /**
      * Constructor for {@link AbstractIoService}. You need to provide a default
@@ -208,8 +198,6 @@
         }
 
         threadName = getClass().getSimpleName() + '-' + id.incrementAndGet();
-
-        executeWorker(idleStatusChecker.getNotifyingTask(), "idleStatusChecker");
     }
 
     /**
@@ -300,8 +288,7 @@
                 }
             }
         }
-
-        idleStatusChecker.getNotifyingTask().cancel();
+        
         if (disposalFuture != null) {
             disposalFuture.awaitUninterruptibly();
         }
@@ -398,13 +385,6 @@
     /**
      * {@inheritDoc}
      */
-    public IoServiceIdleState getIdleState() {
-        return idleState;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public IoServiceStatistics getStatistics() {
         return stats;
     }
@@ -442,9 +422,6 @@
         return listeners;
     }
 
-    protected final IdleStatusChecker getIdleStatusChecker() {
-        return idleStatusChecker;
-    }
 
     protected final void executeWorker(Runnable worker) {
         executeWorker(worker, null);
@@ -561,10 +538,4 @@
         return stats.getScheduledWriteMessages();
     }
     
-    /**
-     * TODO
-     */    
-    public void notifyIdleness(long currentTime) {
-        idleState.notifyIdleness(currentTime);
-    }
 }

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/service/IoProcessor.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/service/IoProcessor.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/service/IoProcessor.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/service/IoProcessor.java Fri Nov 14 01:27:16 2008
@@ -69,10 +69,11 @@
     void flush(T session);
 
     /**
-     * Controls the traffic of the specified {@code session} as specified
-     * in {@link IoSession#getTrafficMask()}.
+     * Controls the traffic of the specified {@code session} depending of the
+     * {@link IoSession#isReadSuspended()} and {@link IoSession#isWriteSuspended()}
+     * flags
      */
-    void updateTrafficMask(T session);
+    void updateTrafficControl(T session);
 
     /**
      * Removes and closes the specified {@code session} from the I/O

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/service/IoService.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/service/IoService.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/service/IoService.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/service/IoService.java Fri Nov 14 01:27:16 2008
@@ -190,13 +190,6 @@
     int getScheduledWriteMessages();
 
     /**
-     * Returns the IoServiceIdleState for this service.
-     * 
-     * @return The idle state object for this service.
-     */
-    IoServiceIdleState getIdleState();
-
-    /**
      * Returns the IoServiceStatistics object for this service.
      * 
      * @return The statistics object for this service.

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java Fri Nov 14 01:27:16 2008
@@ -27,12 +27,11 @@
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import org.apache.mina.core.filterchain.IoFilterChain;
 import org.apache.mina.core.future.IoFuture;
 import org.apache.mina.core.future.IoFutureListener;
-import org.apache.mina.core.session.IdleStatus;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.util.ExceptionMonitor;
-import org.apache.mina.core.filterchain.IoFilterChain;
 
 /**
  * A helper which provides addition and removal of {@link IoServiceListener}s and firing
@@ -136,25 +135,6 @@
     }
 
     /**
-     * Calls {@link IoServiceListener#serviceIdle(IoService, IdleStatus)}
-     * for all registered listeners.
-     */
-    public void fireServiceIdle(IdleStatus status) {
-        if (!activated.get()) {
-            return;
-        }
-
-        for (IoServiceListener l : listeners) {
-            try {
-                l.serviceIdle(service, status);
-            } catch (Throwable e) {
-                ExceptionMonitor.getInstance().exceptionCaught(e);
-            }
-        }
-    }
-
-
-    /**
      * Calls {@link IoServiceListener#serviceDeactivated(IoService)}
      * for all registered listeners.
      */
@@ -266,7 +246,7 @@
         IoFutureListener<IoFuture> listener = new LockNotifyingListener(lock);
 
         for (IoSession s : managedSessions.values()) {
-            s.close().addListener(listener);
+            s.close(true).addListener(listener);
         }
 
         try {

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java Fri Nov 14 01:27:16 2008
@@ -315,7 +315,6 @@
     public final void increaseReadBytes(long increment, long currentTime) {
         readBytes.addAndGet(increment);
         lastReadTime = currentTime;
-        service.getIdleState().resetIdleCountForRead();
     }
 
     /**
@@ -324,7 +323,6 @@
     public final void increaseReadMessages(long currentTime) {
         readMessages.incrementAndGet();
         lastReadTime = currentTime;
-        service.getIdleState().resetIdleCountForRead();
     }
     
     /**
@@ -333,7 +331,6 @@
     public final void increaseWrittenBytes(int increment, long currentTime) {
         writtenBytes.addAndGet(increment);
         lastWriteTime = currentTime;
-        service.getIdleState().resetIdleCountForWrite();
     }
 
     /**
@@ -342,7 +339,6 @@
     public final void increaseWrittenMessages(long currentTime) {
         writtenMessages.incrementAndGet();
         lastWriteTime = currentTime;
-        service.getIdleState().resetIdleCountForWrite();
     }
     
     /**

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/service/SimpleIoProcessorPool.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/service/SimpleIoProcessorPool.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/service/SimpleIoProcessorPool.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/service/SimpleIoProcessorPool.java Fri Nov 14 01:27:16 2008
@@ -189,8 +189,8 @@
         getProcessor(session).remove(session);
     }
 
-    public final void updateTrafficMask(T session) {
-        getProcessor(session).updateTrafficMask(session);
+    public final void updateTrafficControl(T session) {
+        getProcessor(session).updateTrafficControl(session);
     }
     
     public boolean isDisposed() {

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/session/AbstractIoSession.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/session/AbstractIoSession.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/session/AbstractIoSession.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/session/AbstractIoSession.java Fri Nov 14 01:27:16 2008
@@ -24,6 +24,7 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 import java.nio.channels.FileChannel;
+import java.util.Iterator;
 import java.util.Queue;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -48,6 +49,7 @@
 import org.apache.mina.core.write.WriteException;
 import org.apache.mina.core.write.WriteRequest;
 import org.apache.mina.core.write.WriteRequestQueue;
+import org.apache.mina.core.write.WriteTimeoutException;
 import org.apache.mina.core.write.WriteToClosedSessionException;
 import org.apache.mina.util.CircularQueue;
 import org.apache.mina.util.ExceptionMonitor;
@@ -102,7 +104,10 @@
     private final CloseFuture closeFuture = new DefaultCloseFuture(this);
 
     private volatile boolean closing;
-    private volatile TrafficMask trafficMask = TrafficMask.ALL;
+    
+    // traffic control
+    private boolean readSuspended=false;
+    private boolean writeSuspended=false;
 
     // Status variables
     private final AtomicBoolean scheduledForFlush = new AtomicBoolean();
@@ -220,10 +225,7 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public final CloseFuture close() {
+    private final CloseFuture close() {
         synchronized (lock) {
             if (isClosing()) {
                 return closeFuture;
@@ -236,10 +238,7 @@
         return closeFuture;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public final CloseFuture closeOnFlush() {
+    private final CloseFuture closeOnFlush() {
         getWriteRequestQueue().offer(this, CLOSE_REQUEST);
         getProcessor().flush(this);
         return closeFuture;
@@ -548,63 +547,67 @@
             new CloseRequestAwareWriteRequestQueue(writeRequestQueue);
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public final TrafficMask getTrafficMask() {
-        return trafficMask;
-    }
 
     /**
      * {@inheritDoc}
      */
-    public final void setTrafficMask(TrafficMask trafficMask) {
-        if (trafficMask == null) {
-            throw new NullPointerException("trafficMask");
-        }
-
+    public final void suspendRead() {
+        readSuspended = true;
         if (isClosing() || !isConnected()) {
             return;
         }
-
-        getFilterChain().fireFilterSetTrafficMask(trafficMask);
+        getProcessor().updateTrafficControl(this);
     }
 
     /**
-     * TODO Add method documentation
+     * {@inheritDoc}
      */
-    public final void setTrafficMaskNow(TrafficMask trafficMask) {
-        this.trafficMask = trafficMask;
+    public final void suspendWrite() {
+        writeSuspended = true;
+        if (isClosing() || !isConnected()) {
+            return;
+        }
+        getProcessor().updateTrafficControl(this);
     }
 
     /**
      * {@inheritDoc}
      */
-    public final void suspendRead() {
-        setTrafficMask(getTrafficMask().and(TrafficMask.READ.not()));
+    @SuppressWarnings("unchecked")
+	public final void resumeRead() {
+        readSuspended = false;
+        if (isClosing() || !isConnected()) {
+            return;
+        }
+        getProcessor().updateTrafficControl(this);
     }
 
     /**
      * {@inheritDoc}
      */
-    public final void suspendWrite() {
-        setTrafficMask(getTrafficMask().and(TrafficMask.WRITE.not()));
+    @SuppressWarnings("unchecked")
+	public final void resumeWrite() {
+        writeSuspended = false;
+        if (isClosing() || !isConnected()) {
+            return;
+        }
+        getProcessor().updateTrafficControl(this);
     }
 
     /**
      * {@inheritDoc}
      */
-    public final void resumeRead() {
-        setTrafficMask(getTrafficMask().or(TrafficMask.READ));
+    public boolean isReadSuspended() {
+    	return readSuspended;
     }
 
     /**
      * {@inheritDoc}
      */
-    public final void resumeWrite() {
-        setTrafficMask(getTrafficMask().or(TrafficMask.WRITE));
+    public boolean isWriteSuspended() {
+    	return writeSuspended; 
     }
-
+    
     /**
      * {@inheritDoc}
      */
@@ -1153,6 +1156,81 @@
     }
 
     /**
+     * Fires a {@link IoEventType#SESSION_IDLE} event to any applicable
+     * sessions in the specified collection.
+     *
+     * @param currentTime the current time (i.e. {@link System#currentTimeMillis()})
+     */
+    public static void notifyIdleness(Iterator<? extends IoSession> sessions, long currentTime) {
+        IoSession s = null;
+        while (sessions.hasNext()) {
+            s = sessions.next();
+            notifyIdleSession(s, currentTime);
+        }
+    }
+
+    /**
+     * Fires a {@link IoEventType#SESSION_IDLE} event if applicable for the
+     * specified {@code session}.
+     *
+     * @param currentTime the current time (i.e. {@link System#currentTimeMillis()})
+     */
+    public static void notifyIdleSession(IoSession session, long currentTime) {
+        notifyIdleSession0(
+                session, currentTime,
+                session.getConfig().getIdleTimeInMillis(IdleStatus.BOTH_IDLE),
+                IdleStatus.BOTH_IDLE, Math.max(
+                    session.getLastIoTime(),
+                    session.getLastIdleTime(IdleStatus.BOTH_IDLE)));
+
+        notifyIdleSession0(
+                session, currentTime,
+                session.getConfig().getIdleTimeInMillis(IdleStatus.READER_IDLE),
+                IdleStatus.READER_IDLE, Math.max(
+                    session.getLastReadTime(),
+                    session.getLastIdleTime(IdleStatus.READER_IDLE)));
+
+        notifyIdleSession0(
+                session, currentTime,
+                session.getConfig().getIdleTimeInMillis(IdleStatus.WRITER_IDLE),
+                IdleStatus.WRITER_IDLE, Math.max(
+                    session.getLastWriteTime(),
+                    session.getLastIdleTime(IdleStatus.WRITER_IDLE)));
+
+        notifyWriteTimeout(session, currentTime);
+    }
+
+    private static void notifyIdleSession0(
+            IoSession session, long currentTime,
+            long idleTime, IdleStatus status, long lastIoTime) {
+        if (idleTime > 0 && lastIoTime != 0
+                && currentTime - lastIoTime >= idleTime) {
+            session.getFilterChain().fireSessionIdle(status);
+        }
+    }
+
+    private static void notifyWriteTimeout(
+            IoSession session, long currentTime) {
+
+        long writeTimeout = session.getConfig().getWriteTimeoutInMillis();
+        if (writeTimeout > 0 &&
+                currentTime - session.getLastWriteTime() >= writeTimeout &&
+                !session.getWriteRequestQueue().isEmpty(session)) {
+            WriteRequest request = session.getCurrentWriteRequest();
+            if (request != null) {
+                session.setCurrentWriteRequest(null);
+                WriteTimeoutException cause = new WriteTimeoutException(request);
+                request.getFuture().setException(cause);
+                session.getFilterChain().fireExceptionCaught(cause);
+                // WriteException is an IOException, so we close the session.
+                session.close(true);
+            }
+        }
+    }
+
+    
+    
+    /**
      * TODO Add method documentation. Name is ridiculously too long.
      */
     private class CloseRequestAwareWriteRequestQueue implements WriteRequestQueue {

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/session/DummySession.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/session/DummySession.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/session/DummySession.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/session/DummySession.java Fri Nov 14 01:27:16 2008
@@ -78,7 +78,7 @@
     };
 
     private final IoFilterChain filterChain = new DefaultIoFilterChain(this);
-    private final IoProcessor<IoSession> processor;
+    private final IoProcessor<AbstractIoSession> processor;
 
     private volatile IoHandler handler = new IoHandlerAdapter();
     private volatile SocketAddress localAddress = ANONYMOUS_ADDRESS;
@@ -128,11 +128,11 @@
 
         service = acceptor;
 
-        processor = new IoProcessor<IoSession>() {
-            public void add(IoSession session) {
+        processor = new IoProcessor<AbstractIoSession>() {
+            public void add(AbstractIoSession session) {
             }
 
-            public void flush(IoSession session) {
+            public void flush(AbstractIoSession session) {
                 DummySession s = (DummySession) session;
                 WriteRequest req = s.getWriteRequestQueue().poll(session);
                 Object m = req.getMessage();
@@ -148,10 +148,10 @@
                 getFilterChain().fireMessageSent(req);
             }
 
-            public void remove(IoSession session) {
+            public void remove(AbstractIoSession session) {
             }
 
-            public void updateTrafficMask(IoSession session) {
+            public void updateTrafficControl(AbstractIoSession session) {
             }
 
             public void dispose() {
@@ -164,6 +164,7 @@
             public boolean isDisposing() {
                 return false;
             }
+
         };
 
         try {
@@ -256,7 +257,7 @@
     }
 
     @Override
-    public final IoProcessor<IoSession> getProcessor() {
+    public final IoProcessor<AbstractIoSession> getProcessor() {
         return processor;
     }
 

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/session/ExpiringSessionRecycler.java Fri Nov 14 01:27:16 2008
@@ -110,7 +110,7 @@
     private class DefaultExpirationListener implements
             ExpirationListener<IoSession> {
         public void expired(IoSession expiredSession) {
-            expiredSession.close();
+            expiredSession.close(true);
         }
     }
 }

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/session/IdleStatusChecker.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/session/IdleStatusChecker.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/session/IdleStatusChecker.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/session/IdleStatusChecker.java Fri Nov 14 01:27:16 2008
@@ -25,55 +25,75 @@
 import org.apache.mina.core.future.CloseFuture;
 import org.apache.mina.core.future.IoFuture;
 import org.apache.mina.core.future.IoFutureListener;
-import org.apache.mina.core.service.AbstractIoService;
 import org.apache.mina.core.service.IoService;
-import org.apache.mina.core.write.WriteRequest;
-import org.apache.mina.core.write.WriteTimeoutException;
 import org.apache.mina.util.ConcurrentHashSet;
 
 /**
  * Detects idle sessions and fires <tt>sessionIdle</tt> events to them.
+ * To be used for service unable to trigger idle events alone, like VmPipe
+ * or SerialTransport. Polling base transport are advised to trigger idle 
+ * events alone, using the poll/select timeout. 
  *
  * @author The Apache MINA Project (dev@mina.apache.org)
  * @version $Rev: 525369 $, $Date: 2007-04-04 05:05:11 +0200 (mer., 04 avr. 2007) $
  */
 public class IdleStatusChecker {
-    private final Set<AbstractIoSession> sessions =
+    
+	// the list of session to check
+	private final Set<AbstractIoSession> sessions =
         new ConcurrentHashSet<AbstractIoSession>();
-    private final Set<AbstractIoService> services =
-        new ConcurrentHashSet<AbstractIoService>();
 
+    /* create a task you can execute in the transport code,
+     * if the transport is like NIO or APR you don't need to call it,
+     * you just need to call the needed static sessions on select()/poll() 
+     * timeout.
+     */ 
     private final NotifyingTask notifyingTask = new NotifyingTask();
+    
     private final IoFutureListener<IoFuture> sessionCloseListener =
         new SessionCloseListener();
 
     public IdleStatusChecker() {}
 
+    /**
+     * Add the session for being checked for idle. 
+     * @param session the session to check
+     */
     public void addSession(AbstractIoSession session) {
         sessions.add(session);
         CloseFuture closeFuture = session.getCloseFuture();
+        
+        // isn't service reponsability to remove the session nicely ?
         closeFuture.addListener(sessionCloseListener);
     }
 
-    public void addService(AbstractIoService service) {
-        services.add(service);
-    }
-
-    public void removeSession(AbstractIoSession session) {
+    /**
+     * remove a session from the list of session being checked.
+     * @param session
+     */
+    private void removeSession(AbstractIoSession session) {
         sessions.remove(session);
     }
 
-    public void removeService(AbstractIoService service) {
-        services.remove(service);
-    }
-
+    /**
+     * get a runnable task able to be scheduled in the {@link IoService} executor.
+     * @return
+     */
     public NotifyingTask getNotifyingTask() {
         return notifyingTask;
     }
 
+    /**
+     * The class to place in the transport executor for checking the sessions idle 
+     */
     public class NotifyingTask implements Runnable {
         private volatile boolean cancelled;
         private volatile Thread thread;
+        
+        // we forbid instantiation of this class outside
+        private NotifyingTask() {
+        	
+        }
 
         public void run() {
             thread = Thread.currentThread();
@@ -81,7 +101,7 @@
                 while (!cancelled) {
                     // Check idleness with fixed delay (1 second).
                     long currentTime = System.currentTimeMillis();
-                    notifyServices(currentTime);
+
                     notifySessions(currentTime);
 
                     try {
@@ -95,6 +115,9 @@
             }
         }
 
+        /**
+         * stop execution of the task
+         */
         public void cancel() {
             cancelled = true;
             Thread thread = this.thread;
@@ -103,22 +126,12 @@
             }
         }
 
-        private void notifyServices(long currentTime) {
-            Iterator<AbstractIoService> it = services.iterator();
-            while (it.hasNext()) {
-                AbstractIoService service = it.next();
-                if (service.isActive()) {
-                    notifyIdleness(service, currentTime, false);
-                }
-            }
-        }
-
         private void notifySessions(long currentTime) {
             Iterator<AbstractIoSession> it = sessions.iterator();
             while (it.hasNext()) {
                 AbstractIoSession session = it.next();
                 if (session.isConnected()) {
-                    notifyIdleSession(session, currentTime);
+                    AbstractIoSession.notifyIdleSession(session, currentTime);
                 }
             }
         }
@@ -129,99 +142,4 @@
             removeSession((AbstractIoSession) future.getSession());
         }
     }
-
-    /**
-     * Fires a {@link IoEventType#SESSION_IDLE} event to any applicable
-     * sessions in the specified collection.
-     *
-     * @param currentTime the current time (i.e. {@link System#currentTimeMillis()})
-     */
-    public static void notifyIdleness(Iterator<? extends IoSession> sessions, long currentTime) {
-        IoSession s = null;
-        while (sessions.hasNext()) {
-            s = sessions.next();
-            notifyIdleSession(s, currentTime);
-        }
-    }
-
-    public static void notifyIdleness(IoService service, long currentTime) {
-        notifyIdleness(service, currentTime, true);
-    }
-
-    private static void notifyIdleness(IoService service, long currentTime, boolean includeSessions) {
-        if (!(service instanceof AbstractIoService)) {
-            return;
-        }
-
-        ((AbstractIoService) service).notifyIdleness(currentTime);
-
-        if (includeSessions) {
-            notifyIdleness(service.getManagedSessions().values().iterator(), currentTime);
-        }
-    }
-
-    /**
-     * Fires a {@link IoEventType#SESSION_IDLE} event if applicable for the
-     * specified {@code session}.
-     *
-     * @param currentTime the current time (i.e. {@link System#currentTimeMillis()})
-     */
-    public static void notifyIdleSession(IoSession session, long currentTime) {
-        notifyIdleSession0(
-                session, currentTime,
-                session.getConfig().getIdleTimeInMillis(IdleStatus.BOTH_IDLE),
-                IdleStatus.BOTH_IDLE, Math.max(
-                    session.getLastIoTime(),
-                    session.getLastIdleTime(IdleStatus.BOTH_IDLE)));
-
-        notifyIdleSession0(
-                session, currentTime,
-                session.getConfig().getIdleTimeInMillis(IdleStatus.READER_IDLE),
-                IdleStatus.READER_IDLE, Math.max(
-                    session.getLastReadTime(),
-                    session.getLastIdleTime(IdleStatus.READER_IDLE)));
-
-        notifyIdleSession0(
-                session, currentTime,
-                session.getConfig().getIdleTimeInMillis(IdleStatus.WRITER_IDLE),
-                IdleStatus.WRITER_IDLE, Math.max(
-                    session.getLastWriteTime(),
-                    session.getLastIdleTime(IdleStatus.WRITER_IDLE)));
-
-        notifyWriteTimeout(session, currentTime);
-        updateThroughput(session, currentTime);
-    }
-
-    private static void notifyIdleSession0(
-            IoSession session, long currentTime,
-            long idleTime, IdleStatus status, long lastIoTime) {
-        if (idleTime > 0 && lastIoTime != 0
-                && currentTime - lastIoTime >= idleTime) {
-            session.getFilterChain().fireSessionIdle(status);
-        }
-    }
-
-    private static void notifyWriteTimeout(
-            IoSession session, long currentTime) {
-
-        long writeTimeout = session.getConfig().getWriteTimeoutInMillis();
-        if (writeTimeout > 0 &&
-                currentTime - session.getLastWriteTime() >= writeTimeout &&
-                !session.getWriteRequestQueue().isEmpty(session)) {
-            WriteRequest request = session.getCurrentWriteRequest();
-            if (request != null) {
-                session.setCurrentWriteRequest(null);
-                WriteTimeoutException cause = new WriteTimeoutException(request);
-                request.getFuture().setException(cause);
-                session.getFilterChain().fireExceptionCaught(cause);
-                // WriteException is an IOException, so we close the session.
-                session.close();
-            }
-        }
-    }
-
-    private static void updateThroughput(
-            IoSession session, long currentTime) {
-        session.updateThroughput(currentTime, false);
-    }
 }
\ No newline at end of file

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/session/IoEvent.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/session/IoEvent.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/session/IoEvent.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/session/IoEvent.java Fri Nov 14 01:27:16 2008
@@ -75,9 +75,6 @@
         case WRITE:
             getSession().getFilterChain().fireFilterWrite((WriteRequest) getParameter());
             break;
-        case SET_TRAFFIC_MASK:
-            getSession().getFilterChain().fireFilterSetTrafficMask((TrafficMask) getParameter());
-            break;
         case CLOSE:
             getSession().getFilterChain().fireFilterClose();
             break;

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/session/IoEventType.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/session/IoEventType.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/session/IoEventType.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/session/IoEventType.java Fri Nov 14 01:27:16 2008
@@ -37,5 +37,4 @@
     EXCEPTION_CAUGHT,
     WRITE,
     CLOSE,
-    SET_TRAFFIC_MASK,
 }

Modified: mina/trunk/core/src/main/java/org/apache/mina/core/session/IoSession.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/session/IoSession.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/core/session/IoSession.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/core/session/IoSession.java Fri Nov 14 01:27:16 2008
@@ -161,20 +161,6 @@
     WriteFuture write(Object message, SocketAddress destination);
 
     /**
-     * Closes this session immediately.  This operation is asynchronous.
-     * Wait for the returned {@link CloseFuture} if you want to wait for
-     * the session actually closed.
-     */
-    CloseFuture close();
-
-    /**
-     * Closes this session after all queued write requests are flushed.
-     * This operation is asynchronous.  Wait for the returned {@link CloseFuture}
-     * if you want to wait for the session actually closed.
-     */
-    CloseFuture closeOnFlush();
-
-    /**
      * Closes this session immediately or after all queued write requests
      * are flushed.  This operation is asynchronous.  Wait for the returned
      * {@link CloseFuture} if you want to wait for the session actually closed.
@@ -366,18 +352,6 @@
     SocketAddress getServiceAddress();
 
     /**
-     * Returns the current {@link TrafficMask} of this session.
-     */
-    TrafficMask getTrafficMask();
-
-    /**
-     * Sets the {@link TrafficMask} of this session which will result
-     * the parent {@link IoService} to start to control the traffic
-     * of this session immediately.
-     */
-    void setTrafficMask(TrafficMask trafficMask);
-
-    /**
      * 
      * TODO setWriteRequestQueue.
      *
@@ -386,18 +360,38 @@
     void setCurrentWriteRequest(WriteRequest currentWriteRequest);
     
     /**
-     * A shortcut method for {@link #setTrafficMask(TrafficMask)} that
-     * suspends read operations for this session.
+     * Suspends read operations for this session.
      */
     void suspendRead();
 
     /**
-     * A shortcut method for {@link #setTrafficMask(TrafficMask)} that
-     * suspends write operations for this session.
+     * Suspends write operations for this session.
      */
     void suspendWrite();
 
     /**
+     * Resumes read operations for this session.
+     */
+    void resumeRead();
+
+    /**
+     * Resumes write operations for this session.
+     */
+    void resumeWrite();
+    
+    /**
+     * Is read operation is suspended for this session. 
+     * @return <code>true</code> if suspended
+     */
+    boolean isReadSuspended();
+    
+    /**
+     * Is write operation is suspended for this session.
+     * @return <code>true</code> if suspended
+     */
+    boolean isWriteSuspended();
+    
+    /**
      * Update all statistical properties related with throughput assuming
      * the specified time is the current time.  By default this method returns
      * silently without updating the throughput properties if they were
@@ -411,18 +405,6 @@
     void updateThroughput(long currentTime, boolean force);
     
     /**
-     * A shortcut method for {@link #setTrafficMask(TrafficMask)} that
-     * resumes read operations for this session.
-     */
-    void resumeRead();
-
-    /**
-     * A shortcut method for {@link #setTrafficMask(TrafficMask)} that
-     * resumes write operations for this session.
-     */
-    void resumeWrite();
-
-    /**
      * Returns the total number of bytes which were read from this session.
      */
     long getReadBytes();

Modified: mina/trunk/core/src/main/java/org/apache/mina/filter/firewall/BlacklistFilter.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/firewall/BlacklistFilter.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/firewall/BlacklistFilter.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/firewall/BlacklistFilter.java Fri Nov 14 01:27:16 2008
@@ -229,7 +229,7 @@
 
     private void blockSession(IoSession session) {
         logger.warn("Remote address in the blacklist; closing.");
-        session.close();
+        session.close(true);
     }
 
     private boolean isBlocked(IoSession session) {

Modified: mina/trunk/core/src/main/java/org/apache/mina/filter/firewall/ConnectionThrottleFilter.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/firewall/ConnectionThrottleFilter.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/firewall/ConnectionThrottleFilter.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/firewall/ConnectionThrottleFilter.java Fri Nov 14 01:27:16 2008
@@ -123,7 +123,7 @@
             throws Exception {
         if (!isConnectionOk(session)) {
             logger.warn("Connections coming in too fast; closing.");
-            session.close();
+            session.close(true);
         }
         nextFilter.sessionCreated(session);
     }

Modified: mina/trunk/core/src/main/java/org/apache/mina/filter/keepalive/KeepAliveRequestTimeoutHandler.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/keepalive/KeepAliveRequestTimeoutHandler.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/keepalive/KeepAliveRequestTimeoutHandler.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/keepalive/KeepAliveRequestTimeoutHandler.java Fri Nov 14 01:27:16 2008
@@ -79,7 +79,7 @@
             log.warn("Closing the session because a keep-alive response " +
                     "message was not received within {} second(s).",
                     filter.getRequestTimeout());
-            session.close();
+            session.close(true);
         }
     };
 

Modified: mina/trunk/core/src/main/java/org/apache/mina/filter/util/ReferenceCountingFilter.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/util/ReferenceCountingFilter.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/util/ReferenceCountingFilter.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/util/ReferenceCountingFilter.java Fri Nov 14 01:27:16 2008
@@ -24,7 +24,6 @@
 import org.apache.mina.core.filterchain.IoFilterChain;
 import org.apache.mina.core.session.IdleStatus;
 import org.apache.mina.core.session.IoSession;
-import org.apache.mina.core.session.TrafficMask;
 import org.apache.mina.core.write.WriteRequest;
 
 /**
@@ -128,9 +127,4 @@
             throws Exception {
         filter.sessionOpened(nextFilter, session);
     }
-
-    public void filterSetTrafficMask(NextFilter nextFilter, IoSession session,
-            TrafficMask trafficMask) throws Exception {
-        filter.filterSetTrafficMask(nextFilter, session, trafficMask);
-    }
 }

Modified: mina/trunk/core/src/main/java/org/apache/mina/handler/demux/ExceptionHandler.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/handler/demux/ExceptionHandler.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/handler/demux/ExceptionHandler.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/handler/demux/ExceptionHandler.java Fri Nov 14 01:27:16 2008
@@ -46,7 +46,7 @@
      */
     static ExceptionHandler<Throwable> CLOSE = new ExceptionHandler<Throwable>() {
         public void exceptionCaught(IoSession session, Throwable cause) {
-            session.close();
+            session.close(true);
         }
     };
 

Modified: mina/trunk/core/src/main/java/org/apache/mina/handler/stream/IoSessionOutputStream.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/handler/stream/IoSessionOutputStream.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/handler/stream/IoSessionOutputStream.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/handler/stream/IoSessionOutputStream.java Fri Nov 14 01:27:16 2008
@@ -48,7 +48,7 @@
         try {
             flush();
         } finally {
-            session.close().awaitUninterruptibly();
+            session.close(true).awaitUninterruptibly();
         }
     }
 

Modified: mina/trunk/core/src/main/java/org/apache/mina/handler/stream/StreamIoHandler.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/handler/stream/StreamIoHandler.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/handler/stream/StreamIoHandler.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/handler/stream/StreamIoHandler.java Fri Nov 14 01:27:16 2008
@@ -157,7 +157,7 @@
             in.throwException(e);
         } else {
             logger.warn("Unexpected exception.", cause);
-            session.close();
+            session.close(true);
         }
     }
 

Modified: mina/trunk/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java Fri Nov 14 01:27:16 2008
@@ -200,7 +200,7 @@
             logger.error(message);
         }
 
-        getSession().close();
+        getSession().close(true);
     }
 
     protected void closeSession(final String message) {

Modified: mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java Fri Nov 14 01:27:16 2008
@@ -32,6 +32,7 @@
 import org.apache.mina.core.service.AbstractIoAcceptor;
 import org.apache.mina.core.service.IoHandler;
 import org.apache.mina.core.service.TransportMetadata;
+import org.apache.mina.core.session.IdleStatusChecker;
 import org.apache.mina.core.session.IoSession;
 
 /**
@@ -42,6 +43,10 @@
  * @version $Rev$, $Date$
  */
 public final class VmPipeAcceptor extends AbstractIoAcceptor {
+	
+	// object used for checking session idle
+	private IdleStatusChecker idleChecker;
+	
     static final Map<VmPipeAddress, VmPipe> boundHandlers = new HashMap<VmPipeAddress, VmPipe>();
 
     /**
@@ -56,6 +61,10 @@
      */
     public VmPipeAcceptor(Executor executor) {
         super(new DefaultVmPipeSessionConfig(), executor);
+        idleChecker = new IdleStatusChecker();
+        // we schedule the idle status checking task in this service exceutor
+        // it will be woke up every seconds
+        executeWorker(idleChecker.getNotifyingTask(), "idleStatusChecker");
     }
 
     public TransportMetadata getTransportMetadata() {
@@ -86,6 +95,8 @@
 
     @Override
     protected IoFuture dispose0() throws Exception {
+    	// stop the idle checking task
+    	idleChecker.getNotifyingTask().cancel();
         unbind();
         return null;
     }

Modified: mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java Fri Nov 14 01:27:16 2008
@@ -33,6 +33,7 @@
 import org.apache.mina.core.service.AbstractIoConnector;
 import org.apache.mina.core.service.IoHandler;
 import org.apache.mina.core.service.TransportMetadata;
+import org.apache.mina.core.session.IdleStatusChecker;
 import org.apache.mina.core.session.IoSessionInitializer;
 import org.apache.mina.util.ExceptionMonitor;
 
@@ -45,6 +46,9 @@
  */
 public final class VmPipeConnector extends AbstractIoConnector {
 
+	// object used for checking session idle
+	private IdleStatusChecker idleChecker;
+	
     /**
      * Creates a new instance.
      */
@@ -57,6 +61,10 @@
      */
     public VmPipeConnector(Executor executor) {
         super(new DefaultVmPipeSessionConfig(), executor);
+        idleChecker = new IdleStatusChecker();
+        // we schedule the idle status checking task in this service exceutor
+        // it will be woke up every seconds
+        executeWorker(idleChecker.getNotifyingTask(), "idleStatusChecker");
     }
 
     public TransportMetadata getTransportMetadata() {
@@ -103,7 +111,7 @@
 
             // The following sentences don't throw any exceptions.
             getListeners().fireSessionCreated(localSession);
-            getIdleStatusChecker().addSession(localSession);
+            idleChecker.addSession(localSession);
         } catch (Throwable t) {
             future.setException(t);
             return future;
@@ -119,10 +127,10 @@
 
             // The following sentences don't throw any exceptions.
             entry.getListeners().fireSessionCreated(remoteSession);
-            getIdleStatusChecker().addSession(remoteSession);
+            idleChecker.addSession(remoteSession);
         } catch (Throwable t) {
             ExceptionMonitor.getInstance().exceptionCaught(t);
-            remoteSession.close();
+            remoteSession.close(true);
         }
 
         // Start chains, and then allow and messages read/written to be processed. This is to ensure that
@@ -135,6 +143,8 @@
 
     @Override
     protected IoFuture dispose0() throws Exception {
+    	// stop the idle checking task
+    	idleChecker.getNotifyingTask().cancel();
         return null;
     }
 

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=713957&r1=713956&r2=713957&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 Fri Nov 14 01:27:16 2008
@@ -87,9 +87,9 @@
         Object data = e.getParameter();
 
         if (type == IoEventType.MESSAGE_RECEIVED) {
-            if (sessionOpened && session.getTrafficMask().isReadable() && session.getLock().tryLock()) {
+            if (sessionOpened && (! session.isReadSuspended() ) && session.getLock().tryLock()) {
                 try {
-                    if (!session.getTrafficMask().isReadable()) {
+                    if (session.isReadSuspended()) {
                         session.receivedMessageQueue.add(data);
                     } else {
                         super.fireMessageReceived(data);
@@ -127,8 +127,8 @@
     }
 
     private static void flushPendingDataQueues(VmPipeSession s) {
-        s.getProcessor().updateTrafficMask(s);
-        s.getRemoteSession().getProcessor().updateTrafficMask(s);
+        s.getProcessor().updateTrafficControl(s);
+        s.getRemoteSession().getProcessor().updateTrafficControl(s);
     }
 
     @Override
@@ -241,7 +241,7 @@
                 session.getLock().lock();
                 if (!session.getCloseFuture().isClosed()) {
                     session.getServiceListeners().fireSessionDestroyed(session);
-                    session.getRemoteSession().close();
+                    session.getRemoteSession().close(true);
                 }
             } finally {
                 session.getLock().unlock();
@@ -252,8 +252,8 @@
             // Unused
         }
 
-        public void updateTrafficMask(VmPipeSession session) {
-            if (session.getTrafficMask().isReadable()) {
+        public void updateTrafficControl(VmPipeSession session) {
+            if ( ! session.isReadSuspended()) {
                 List<Object> data = new ArrayList<Object>();
                 session.receivedMessageQueue.drainTo(data);
                 for (Object aData : data) {
@@ -261,7 +261,7 @@
                 }
             }
 
-            if (session.getTrafficMask().isWritable()) {
+            if ( ! session.isWriteSuspended()) {
                 flush(session);
             }
         }

Modified: mina/trunk/core/src/test/java/org/apache/mina/filter/buffer/BufferedWriteFilterTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/test/java/org/apache/mina/filter/buffer/BufferedWriteFilterTest.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/test/java/org/apache/mina/filter/buffer/BufferedWriteFilterTest.java (original)
+++ mina/trunk/core/src/test/java/org/apache/mina/filter/buffer/BufferedWriteFilterTest.java Fri Nov 14 01:27:16 2008
@@ -99,6 +99,6 @@
         // Flush the final byte
         bFilter.flush(sess);
         
-        sess.close();
+        sess.close(true);
     }
 }
\ No newline at end of file

Modified: mina/trunk/core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java (original)
+++ mina/trunk/core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java Fri Nov 14 01:27:16 2008
@@ -29,7 +29,6 @@
 import org.apache.mina.core.session.DummySession;
 import org.apache.mina.core.session.IdleStatus;
 import org.apache.mina.core.session.IoSession;
-import org.apache.mina.core.session.TrafficMask;
 import org.apache.mina.core.write.WriteRequest;
 
 /**
@@ -138,9 +137,6 @@
 
         public void sessionCreated(IoSession session) {
         }
-
-        public void filterSetTrafficMask(IoSession session, TrafficMask trafficMask) {
-        }
     }
 
     public static void main(String[] args) {

Modified: mina/trunk/core/src/test/java/org/apache/mina/filter/logging/MdcInjectionFilterTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/test/java/org/apache/mina/filter/logging/MdcInjectionFilterTest.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/test/java/org/apache/mina/filter/logging/MdcInjectionFilterTest.java (original)
+++ mina/trunk/core/src/test/java/org/apache/mina/filter/logging/MdcInjectionFilterTest.java Fri Nov 14 01:27:16 2008
@@ -316,7 +316,7 @@
         public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
             logger.info("sessionIdle");
             sessionIdleLatch.countDown();
-            session.close();
+            session.close(true);
         }
 
         @Override

Modified: mina/trunk/core/src/test/java/org/apache/mina/filter/stream/AbstractStreamWriteFilterTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/test/java/org/apache/mina/filter/stream/AbstractStreamWriteFilterTest.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/test/java/org/apache/mina/filter/stream/AbstractStreamWriteFilterTest.java (original)
+++ mina/trunk/core/src/test/java/org/apache/mina/filter/stream/AbstractStreamWriteFilterTest.java Fri Nov 14 01:27:16 2008
@@ -426,7 +426,7 @@
         @Override
         public void sessionIdle(IoSession session, IdleStatus status)
                 throws Exception {
-            session.close();
+            session.close(true);
         }
 
         @Override
@@ -449,7 +449,7 @@
                 bytesRead++;
             }
             if (bytesRead >= size) {
-                session.close();
+                session.close(true);
             }
         }
     }

Modified: mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractBindTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractBindTest.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractBindTest.java (original)
+++ mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractBindTest.java Fri Nov 14 01:27:16 2008
@@ -226,7 +226,7 @@
         @Override
         public void exceptionCaught(IoSession session, Throwable cause) {
             cause.printStackTrace();
-            session.close();
+            session.close(true);
         }
 
         @Override

Modified: mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractConnectorTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractConnectorTest.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractConnectorTest.java (original)
+++ mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractConnectorTest.java Fri Nov 14 01:27:16 2008
@@ -76,7 +76,7 @@
                     "localhost", port));
             future.awaitUninterruptibly();
             buf.append("3");
-            future.getSession().close();
+            future.getSession().close(true);
             // sessionCreated() will fire before the connect future completes
             // but sessionOpened() may not
             Assert.assertTrue(Pattern.matches("12?32?", buf.toString()));
@@ -113,7 +113,7 @@
             future.awaitUninterruptibly();
             buf.append("1");
             try {
-                future.getSession().close();
+                future.getSession().close(true);
                 fail();
             } catch (RuntimeIoException e) {
                 // OK.

Modified: mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractFileRegionTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractFileRegionTest.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractFileRegionTest.java (original)
+++ mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractFileRegionTest.java Fri Nov 14 01:27:16 2008
@@ -66,7 +66,7 @@
             public void exceptionCaught(IoSession session, Throwable cause)
                     throws Exception {
                 exception[0] = cause;
-                session.close();
+                session.close(true);
             }
             @Override
             public void messageReceived(IoSession session, Object message) throws Exception {
@@ -83,7 +83,7 @@
                 }
                 if (index == FILE_SIZE / 4) {
                     success[0] = true;
-                    session.close();
+                    session.close(true);
                 }
             }
         });
@@ -95,7 +95,7 @@
             public void exceptionCaught(IoSession session, Throwable cause)
                     throws Exception {
                 exception[0] = cause;
-                session.close();
+                session.close(true);
             }
             @Override
             public void sessionClosed(IoSession session) throws Exception {

Modified: mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractTrafficControlTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractTrafficControlTest.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractTrafficControlTest.java (original)
+++ mina/trunk/core/src/test/java/org/apache/mina/transport/AbstractTrafficControlTest.java Fri Nov 14 01:27:16 2008
@@ -162,7 +162,7 @@
 
         }
 
-        session.close().awaitUninterruptibly();
+        session.close(true).awaitUninterruptibly();
     }
 
     private void write(IoSession session, String s) throws Exception {

Modified: mina/trunk/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramConfigTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramConfigTest.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramConfigTest.java (original)
+++ mina/trunk/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramConfigTest.java Fri Nov 14 01:27:16 2008
@@ -83,7 +83,7 @@
             writeFuture.awaitUninterruptibly();
             Assert.assertTrue(writeFuture.isWritten());
 
-            future.getSession().close();
+            future.getSession().close(true);
 
             for (int i = 0; i < 30; i++) {
                 if (result.length() == 2) {

Modified: mina/trunk/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramRecyclerTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramRecyclerTest.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramRecyclerTest.java (original)
+++ mina/trunk/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramRecyclerTest.java Fri Nov 14 01:27:16 2008
@@ -84,8 +84,8 @@
             // Close the client-side connection.
             // This doesn't mean that the acceptor-side connection is also closed.
             // The life cycle of the acceptor-side connection is managed by the recycler.
-            future.getSession().close();
-            future.getSession().getCloseFuture().awaitUninterruptibly();
+            future.getSession().close(true);
+	    future.getSession().getCloseFuture().awaitUninterruptibly();
             Assert.assertTrue(future.getSession().getCloseFuture().isClosed());
 
             // Wait until the acceptor-side connection is closed.
@@ -132,7 +132,7 @@
             while (acceptorHandler.session == null) {
                 Thread.yield();
             }
-            acceptorHandler.session.close();
+            acceptorHandler.session.close(true);
             Assert.assertTrue(
                     acceptorHandler.session.getCloseFuture().awaitUninterruptibly(3000));
             
@@ -158,11 +158,11 @@
             while (acceptorHandler.session == null) {
                 Thread.yield();
             }
-            acceptorHandler.session.close();
+            acceptorHandler.session.close(true);
             Assert.assertTrue(
                     acceptorHandler.session.getCloseFuture().awaitUninterruptibly(3000));
 
-            future.getSession().close().awaitUninterruptibly();
+            future.getSession().close(true).awaitUninterruptibly();
             
             Assert.assertNotSame(oldSession, acceptorHandler.session);
         } finally {

Modified: mina/trunk/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeEventOrderTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeEventOrderTest.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeEventOrderTest.java (original)
+++ mina/trunk/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeEventOrderTest.java Fri Nov 14 01:27:16 2008
@@ -53,7 +53,7 @@
             @Override
             public void messageSent(IoSession session, Object message)
                     throws Exception {
-                session.close();
+                session.close(true);
             }
         });
 
@@ -133,7 +133,7 @@
             @Override
             public void messageSent(IoSession session, Object message)
                     throws Exception {
-                session.close();
+                session.close(true);
             }
         });
 
@@ -194,7 +194,7 @@
         ConnectFuture connectFuture = vmPipeConnector.connect(vmPipeAddress);
         connectFuture.awaitUninterruptibly();
         connectFuture.getSession().write(IoBuffer.wrap(new byte[1]));
-        connectFuture.getSession().closeOnFlush().awaitUninterruptibly();
+        connectFuture.getSession().close(false).awaitUninterruptibly();
 
         semaphore.tryAcquire(1, TimeUnit.SECONDS);
         vmPipeAcceptor.unbind(vmPipeAddress);

Modified: mina/trunk/example/src/main/java/org/apache/mina/example/chat/ChatProtocolHandler.java
URL: http://svn.apache.org/viewvc/mina/trunk/example/src/main/java/org/apache/mina/example/chat/ChatProtocolHandler.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/example/src/main/java/org/apache/mina/example/chat/ChatProtocolHandler.java (original)
+++ mina/trunk/example/src/main/java/org/apache/mina/example/chat/ChatProtocolHandler.java Fri Nov 14 01:27:16 2008
@@ -49,7 +49,7 @@
     public void exceptionCaught(IoSession session, Throwable cause) {
         logger.warn("Unexpected exception.", cause);
         // Close connection when unexpected exception is caught.
-        session.close();
+        session.close(true);
     }
 
     @Override
@@ -69,7 +69,7 @@
 
             case ChatCommand.QUIT:
                 session.write("QUIT OK");
-                session.close();
+                session.close(true);
                 break;
             case ChatCommand.LOGIN:
 
@@ -149,7 +149,7 @@
         synchronized (sessions) {
             for (IoSession session : sessions) {
                 if (name.equals(session.getAttribute("user"))) {
-                    session.close();
+                    session.close(true);
                     break;
                 }
             }

Modified: mina/trunk/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java
URL: http://svn.apache.org/viewvc/mina/trunk/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java (original)
+++ mina/trunk/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java Fri Nov 14 01:27:16 2008
@@ -111,7 +111,7 @@
                 // Wait until the chat ends.
                 session.getCloseFuture().awaitUninterruptibly();
             }
-            session.close();
+            session.close(true);
         }
     }
 

Modified: mina/trunk/example/src/main/java/org/apache/mina/example/echoserver/EchoProtocolHandler.java
URL: http://svn.apache.org/viewvc/mina/trunk/example/src/main/java/org/apache/mina/example/echoserver/EchoProtocolHandler.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/example/src/main/java/org/apache/mina/example/echoserver/EchoProtocolHandler.java (original)
+++ mina/trunk/example/src/main/java/org/apache/mina/example/echoserver/EchoProtocolHandler.java Fri Nov 14 01:27:16 2008
@@ -62,7 +62,7 @@
 
     @Override
     public void exceptionCaught(IoSession session, Throwable cause) {
-        session.close();
+        session.close(true);
     }
 
     @Override

Modified: mina/trunk/example/src/main/java/org/apache/mina/example/gettingstarted/timeserver/TimeServerHandler.java
URL: http://svn.apache.org/viewvc/mina/trunk/example/src/main/java/org/apache/mina/example/gettingstarted/timeserver/TimeServerHandler.java?rev=713957&r1=713956&r2=713957&view=diff
==============================================================================
--- mina/trunk/example/src/main/java/org/apache/mina/example/gettingstarted/timeserver/TimeServerHandler.java (original)
+++ mina/trunk/example/src/main/java/org/apache/mina/example/gettingstarted/timeserver/TimeServerHandler.java Fri Nov 14 01:27:16 2008
@@ -44,7 +44,7 @@
     {
         String str = message.toString();
         if( str.trim().equalsIgnoreCase("quit") ) {
-            session.close();
+            session.close(true);
             return;
         }
 



Mime
View raw message