Bug fix for improper session closure for clients using keep-alive while idling notification is in effect

git-svn-id: https://svn.apache.org/repos/asf/mina/asyncweb/trunk@620698 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/server/src/main/java/org/apache/asyncweb/server/transport/mina/SingleHttpSessionIoHandler.java b/server/src/main/java/org/apache/asyncweb/server/transport/mina/SingleHttpSessionIoHandler.java
index 897ce78..94ec8b9 100644
--- a/server/src/main/java/org/apache/asyncweb/server/transport/mina/SingleHttpSessionIoHandler.java
+++ b/server/src/main/java/org/apache/asyncweb/server/transport/mina/SingleHttpSessionIoHandler.java
@@ -133,7 +133,7 @@
      */
     public void sessionIdle( IdleStatus idleType )
     {
-        if ( session.getIdleCount( idleType ) == 1 )
+        if ( session.getIdleCount( idleType ) >= 1 )
         {
             //      // FIXME currentRequest is always null now; we need to cooperate with a decoder.
             //      if (currentContext != null) {
@@ -141,6 +141,8 @@
             //        handleReadFailure(currentContext, HttpResponseStatus.REQUEST_TIMEOUT, "Timeout while reading request");
             //      } else {
 
+        	LOG.debug( "Session idle detected on context {} with idleType {}", currentContext, idleType );
+        	
             if ( currentContext != null )
             {
                 if ( IdleStatus.BOTH_IDLE == idleType || IdleStatus.READER_IDLE == idleType )
@@ -148,18 +150,19 @@
                     currentContext.fireClientIdle( session.getLastReaderIdleTime(), session.getReaderIdleCount() );
                 }
             }
-
-            // TODO - look further into this - it may present serious issues when dealing with HTTP/1.1 
-            LOG.info( "Idled with no current request. Scheduling closure when pipeline empties" );
-            pipeline.runWhenEmpty( new Runnable()
+            else
             {
-                public void run()
-                {
-                    LOG.info( "Pipeline empty after idle. Closing session" );
-                    session.close();
-                }
-            });
-            //      }
+	            // TODO - look further into this - it may present serious issues when dealing with HTTP/1.1 
+	            LOG.info( "Idled with no current request. Scheduling closure when pipeline empties" );
+	            pipeline.runWhenEmpty( new Runnable()
+	            {
+	                public void run()
+	                {
+	                    LOG.info( "Pipeline empty after idle. Closing session" );
+	                    session.close();
+	                }
+	            });
+            }
         }
     }