directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r123310 - in incubator/directory/network/trunk/mina/src: examples/org/apache/mina/examples/echoserver examples/org/apache/mina/examples/netcat java/org/apache/mina/io/filter java/org/apache/mina/protocol
Date Sat, 25 Dec 2004 04:00:22 GMT
Author: trustin
Date: Fri Dec 24 20:00:21 2004
New Revision: 123310

URL: http://svn.apache.org/viewcvs?view=rev&rev=123310
Log:
There is no need to lock read buffer in dataRead() handler because IoThreadPoolFilter locks
it before invoking dataRead.
Modified:
   incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
   incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/netcat/NetCatProtocolHandler.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java

Modified: incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java?view=diff&rev=123310&p1=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java&r1=123309&p2=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java&r2=123310
==============================================================================
--- incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
(original)
+++ incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
Fri Dec 24 20:00:21 2004
@@ -59,16 +59,13 @@
 
     public void dataRead( IoSession session, ByteBuffer rb )
     {
-        synchronized( rb )
-        {
-            ByteBuffer wb = ByteBuffer.allocate( rb.remaining() );
-            wb.put( rb );
-            wb.flip();
-            System.out.println( Thread.currentThread().getName() + ' '
-                                + session.getRemoteAddress() + ": READ ("
-                                + wb.remaining() + "B)" );
-            session.write( wb, null );
-        }
+        ByteBuffer wb = ByteBuffer.allocate( rb.remaining() );
+        wb.put( rb );
+        wb.flip();
+        System.out.println( Thread.currentThread().getName() + ' '
+                            + session.getRemoteAddress() + ": READ ("
+                            + wb.remaining() + "B)" );
+        session.write( wb, null );
     }
 
     public void dataWritten( IoSession IoSession, Object marker )

Modified: incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/netcat/NetCatProtocolHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/netcat/NetCatProtocolHandler.java?view=diff&rev=123310&p1=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/netcat/NetCatProtocolHandler.java&r1=123309&p2=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/netcat/NetCatProtocolHandler.java&r2=123310
==============================================================================
--- incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/netcat/NetCatProtocolHandler.java
(original)
+++ incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/netcat/NetCatProtocolHandler.java
Fri Dec 24 20:00:21 2004
@@ -49,12 +49,9 @@
 
     public void dataRead( IoSession session, ByteBuffer buf )
     {
-        synchronized( buf )
+        while( buf.hasRemaining() )
         {
-            while( buf.hasRemaining() )
-            {
-                System.out.print( ( char ) buf.get() );
-            }
+            System.out.print( ( char ) buf.get() );
         }
         System.out.flush();
     }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java?view=diff&rev=123310&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java&r1=123309&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java&r2=123310
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java
Fri Dec 24 20:00:21 2004
@@ -388,15 +388,12 @@
             if( type == EventType.READ )
             {
                 ByteBuffer buf = ( ByteBuffer ) data;
-                boolean fire;
                 synchronized( buf )
                 {
-                    fire = buf.hasRemaining();
-                }
-
-                if( fire )
-                {
-                    nextHandler.dataRead( session, buf );
+                    if (buf.hasRemaining())
+                    {
+                        nextHandler.dataRead( session, buf );
+                    }
                 }
             }
             else if( type == EventType.WRITTEN )

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java?view=diff&rev=123310&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java&r1=123309&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java&r2=123310
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java
Fri Dec 24 20:00:21 2004
@@ -103,12 +103,9 @@
             {
                 for( ;; )
                 {
-                    synchronized( in )
+                    if( in.hasRemaining() )
                     {
-                        if( in.hasRemaining() )
-                        {
-                            decoder.decode( psession, in, psession.decOut );
-                        }
+                        decoder.decode( psession, in, psession.decOut );
                     }
 
                     Queue queue = psession.decOut.messageQueue;

Mime
View raw message