directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r151546 - incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/io/IoAdapter.java
Date Sun, 06 Feb 2005 05:33:37 GMT
Author: trustin
Date: Sat Feb  5 21:33:35 2005
New Revision: 151546

URL: http://svn.apache.org/viewcvs?view=rev&rev=151546
Log:
Fixed: DIRMINA-4: ProtocolDecoder receives dirty ByteBuffer in UDP mode.

IoAdapter did not discard unread part of previous ByteBuffer and called decoder.decode() with
it again.
Now IoAdapter discards ByteBuffer even if the decoder didn't read all part of ByteBuffer.
If decoder couldn't decode partial ByteBuffer because the message is not complete, decoder
will have to buffer it to merge with the next ByteBuffer.

Modified:
    incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/io/IoAdapter.java

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/io/IoAdapter.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/io/IoAdapter.java?view=diff&r1=151545&r2=151546
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/io/IoAdapter.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/io/IoAdapter.java
Sat Feb  5 21:33:35 2005
@@ -86,12 +86,12 @@
      */
     public void removeAllFilters()
     {
-    	filterManager.removeAllFilters();
+        filterManager.removeAllFilters();
     }
 
     public List getAllFilters()
     {
-    	return filterManager.filters();
+        return filterManager.filters();
     }
 
     /**
@@ -152,13 +152,13 @@
         public void sessionIdle( IoSession session, IdleStatus status )
         {
             filterManager.fireSessionIdle( getProtocolSession( session ),
-                                           status );
+                    status );
         }
 
         public void exceptionCaught( IoSession session, Throwable cause )
         {
             filterManager.fireExceptionCaught( getProtocolSession( session ),
-                                               cause );
+                    cause );
         }
 
         public void dataRead( IoSession session, ByteBuffer in )
@@ -166,32 +166,22 @@
             ProtocolSessionImpl psession = getProtocolSession( session );
             try
             {
-                for( ;; )
+                synchronized( decoder )
                 {
-                    if( in.hasRemaining() )
-                    {
-                        synchronized (decoder) {
-                            decoder.decode( psession, in, psession.decOut );
-                        }
-                    }
+                    decoder.decode( psession, in, psession.decOut );
+                }
 
-                    Queue queue = psession.decOut.messageQueue;
-                    synchronized( queue )
+                Queue queue = psession.decOut.messageQueue;
+                synchronized( queue )
+                {
+                    if( !queue.isEmpty() )
                     {
-                        if( queue.isEmpty() )
-                        {
-                            break;
-                        }
-                        else
+                        do
                         {
-                            do
-                            {
-                                filterManager
-                                        .fireMessageReceived( psession, queue
-                                                .pop() );
-                            }
-                            while( !queue.isEmpty() );
+                            filterManager.fireMessageReceived( psession,
+                                    queue.pop() );
                         }
+                        while( !queue.isEmpty() );
                     }
                 }
             }
@@ -267,7 +257,8 @@
             {
                 synchronized( session )
                 {
-                    psession = ( ProtocolSessionImpl ) session.getAttachment();
+                    psession = ( ProtocolSessionImpl ) session
+                            .getAttachment();
                     if( psession == null )
                     {
                         psession = new ProtocolSessionImpl( session, this );
@@ -410,7 +401,7 @@
     }
 
     private static class ProtocolEncoderOutputImpl implements
-                                                  ProtocolEncoderOutput
+            ProtocolEncoderOutput
     {
 
         private final Queue queue = new Queue();
@@ -426,7 +417,7 @@
     }
 
     private static class ProtocolDecoderOutputImpl implements
-                                                  ProtocolDecoderOutput
+            ProtocolDecoderOutput
     {
 
         private final Queue messageQueue = new Queue();
@@ -440,4 +431,4 @@
             messageQueue.push( message );
         }
     }
-}
\ No newline at end of file
+}



Mime
View raw message