directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r179047 - in /directory/network: branches/0.7/project.xml branches/0.7/src/java/org/apache/mina/io/socket/SocketIoProcessor.java trunk/src/java/org/apache/mina/transport/socket/nio/SocketIoProcessor.java
Date Mon, 30 May 2005 11:46:52 GMT
Author: trustin
Date: Mon May 30 04:46:50 2005
New Revision: 179047

URL: http://svn.apache.org/viewcvs?rev=179047&view=rev
Log:
Fixed: DIRMINA-47


Modified:
    directory/network/branches/0.7/project.xml
    directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketIoProcessor.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketIoProcessor.java

Modified: directory/network/branches/0.7/project.xml
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/project.xml?rev=179047&r1=179046&r2=179047&view=diff
==============================================================================
--- directory/network/branches/0.7/project.xml (original)
+++ directory/network/branches/0.7/project.xml Mon May 30 04:46:50 2005
@@ -154,9 +154,7 @@
     <report>maven-changes-plugin</report>
     <report>maven-jxr-plugin</report>
     <report>maven-junit-report-plugin</report>
-    <!-- Test fails if enabled.
     <report>maven-emma-plugin</report>
-    -->
     <report>maven-jdepend-plugin</report>
     <report>maven-simian-plugin</report>
     <report>maven-tasklist-plugin</report>

Modified: directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketIoProcessor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketIoProcessor.java?rev=179047&r1=179046&r2=179047&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketIoProcessor.java
(original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketIoProcessor.java
Mon May 30 04:46:50 2005
@@ -190,7 +190,16 @@
 
             SocketChannel ch = session.getChannel();
             SelectionKey key = session.getSelectionKey();
-            if( !key.isValid() ) // skip if channel is already closed
+            // Retry later if session is not yet fully initialized.
+            // (In case that Session.close() is called before addSession() is processed)
+            if( key == null )
+            {
+                scheduleRemove( session );
+                break;
+            }
+
+            // skip if channel is already closed
+            if( !key.isValid() )
             {
                 continue;
             }
@@ -366,6 +375,7 @@
     {
         if( writeTimeout > 0
             && ( currentTime - lastIoTime ) >= writeTimeout
+            && session.getSelectionKey() != null
             && ( session.getSelectionKey().interestOps() & SelectionKey.OP_WRITE
) != 0 )
         {
             session
@@ -397,14 +407,25 @@
                 continue;
             }
 
-            try
+            // If encountered write request before session is initialized, 
+            // (In case that Session.write() is called before addSession() is processed)
+            if( session.getSelectionKey() == null )
             {
-                flush( session );
+                // Reschedule for later write
+                scheduleFlush( session );
+                break;
             }
-            catch( IOException e )
+            else
             {
-                scheduleRemove( session );
-                session.getManagerFilterChain().exceptionCaught( session, e );
+                try
+                {
+                    flush( session );
+                }
+                catch( IOException e )
+                {
+                    scheduleRemove( session );
+                    session.getManagerFilterChain().exceptionCaught( session, e );
+                }
             }
         }
     }
@@ -553,4 +574,4 @@
             }
         }
     }
-}
\ No newline at end of file
+}

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketIoProcessor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketIoProcessor.java?rev=179047&r1=179046&r2=179047&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketIoProcessor.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketIoProcessor.java
Mon May 30 04:46:50 2005
@@ -190,7 +190,16 @@
 
             SocketChannel ch = session.getChannel();
             SelectionKey key = session.getSelectionKey();
-            if( !key.isValid() ) // skip if channel is already closed
+            // Retry later if session is not yet fully initialized.
+            // (In case that Session.close() is called before addSession() is processed)
+            if( key == null )
+            {
+                scheduleRemove( session );
+                break;
+            }
+
+            // skip if channel is already closed
+            if( !key.isValid() )
             {
                 continue;
             }
@@ -366,6 +375,7 @@
     {
         if( writeTimeout > 0
             && ( currentTime - lastIoTime ) >= writeTimeout
+            && session.getSelectionKey() != null
             && ( session.getSelectionKey().interestOps() & SelectionKey.OP_WRITE
) != 0 )
         {
             session
@@ -396,15 +406,26 @@
                 releaseWriteBuffers( session );
                 continue;
             }
-
-            try
+            
+            // If encountered write request before session is initialized, 
+            // (In case that Session.write() is called before addSession() is processed)
+            if( session.getSelectionKey() == null )
             {
-                flush( session );
+                // Reschedule for later write
+                scheduleFlush( session );
+                break;
             }
-            catch( IOException e )
+            else
             {
-                scheduleRemove( session );
-                session.getManagerFilterChain().exceptionCaught( session, e );
+                try
+                {
+                    flush( session );
+                }
+                catch( IOException e )
+                {
+                    scheduleRemove( session );
+                    session.getManagerFilterChain().exceptionCaught( session, e );
+                }
             }
         }
     }



Mime
View raw message