Author: akarasulu
Date: Mon Feb 11 19:50:53 2008
New Revision: 620698

URL: http://svn.apache.org/viewvc?rev=620698&view=rev
Log:
Bug fix for improper session closure for clients using keep-alive while idling 
notification is in effect

Modified:
    
mina/asyncweb/trunk/server/src/main/java/org/apache/asyncweb/server/transport/mina/SingleHttpSessionIoHandler.java

Modified: 
mina/asyncweb/trunk/server/src/main/java/org/apache/asyncweb/server/transport/mina/SingleHttpSessionIoHandler.java
URL: 
http://svn.apache.org/viewvc/mina/asyncweb/trunk/server/src/main/java/org/apache/asyncweb/server/transport/mina/SingleHttpSessionIoHandler.java?rev=620698&r1=620697&r2=620698&view=diff
==============================================================================
--- 
mina/asyncweb/trunk/server/src/main/java/org/apache/asyncweb/server/transport/mina/SingleHttpSessionIoHandler.java
 (original)
+++ 
mina/asyncweb/trunk/server/src/main/java/org/apache/asyncweb/server/transport/mina/SingleHttpSessionIoHandler.java
 Mon Feb 11 19:50:53 2008
@@ -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();
+                       }
+                   });
+            }
         }
     }
 


Reply via email to