Author: rajith
Date: Thu Oct 25 02:55:17 2012
New Revision: 1401959

URL: http://svn.apache.org/viewvc?rev=1401959&view=rev
Log:
PROTON-66 We now register for WRITE_OP if we are unable to write to the
channel. As soon we are successful in writing we deregister the WRITE_OP.

Modified:
    
qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ConnectorImpl.java
    
qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java

Modified: 
qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ConnectorImpl.java
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ConnectorImpl.java?rev=1401959&r1=1401958&r2=1401959&view=diff
==============================================================================
--- 
qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ConnectorImpl.java
 (original)
+++ 
qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ConnectorImpl.java
 Thu Oct 25 02:55:17 2012
@@ -96,11 +96,7 @@ class ConnectorImpl<C> implements Connec
         {
             read();
         }
-
-        if (_key.isWritable())
-        {
-            write();
-        }
+        write();
     }
 
     void read()
@@ -154,6 +150,14 @@ class ConnectorImpl<C> implements Connec
                     _writeBuffer.clear();
                     _bytesNotWritten = 0;
                 }
+                if (_bytesNotWritten > 0) // couldn't write all the data, need 
to know when we could write again.
+                {
+                    _key.interestOps(_key.interestOps() | 
SelectionKey.OP_WRITE);
+                }
+                else if ((_key.interestOps() & SelectionKey.OP_WRITE) != 0)
+                {
+                    _key.interestOps(_key.interestOps() & 
~SelectionKey.OP_WRITE);                    
+                }
             }
         }
         catch (IOException e)

Modified: 
qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java?rev=1401959&r1=1401958&r2=1401959&view=diff
==============================================================================
--- 
qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java
 (original)
+++ 
qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java
 Thu Oct 25 02:55:17 2012
@@ -216,7 +216,7 @@ public class DriverImpl implements Drive
 
     public <C> Connector<C> createConnector(SelectableChannel c, C context)
     {
-        SelectionKey key = registerInterest(c,SelectionKey.OP_READ | 
SelectionKey.OP_WRITE);
+        SelectionKey key = registerInterest(c,SelectionKey.OP_READ);
         Connector<C> co = new ConnectorImpl<C>(this, null, new 
SaslClientImpl(),(SocketChannel)c, context, key);
         key.attach(co);
         return co;
@@ -224,7 +224,7 @@ public class DriverImpl implements Drive
 
     protected <C> Connector<C> createServerConnector(SelectableChannel c, C 
context, Listener<C> l)
     {
-        SelectionKey key = registerInterest(c,SelectionKey.OP_READ | 
SelectionKey.OP_WRITE);
+        SelectionKey key = registerInterest(c,SelectionKey.OP_READ);
         Connector<C> co = new ConnectorImpl<C>(this, l, new 
SaslServerImpl(),(SocketChannel)c, context, key);
         key.attach(co);
         return co;



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to