geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject cvs commit: incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol SocketProtocol.java
Date Sat, 24 Apr 2004 17:56:32 GMT
chirino     2004/04/24 10:56:32

  Modified:    modules/network/src/java/org/apache/geronimo/network/protocol
                        SocketProtocol.java
  Log:
  Better SelectorManager handing.
  
  Revision  Changes    Path
  1.8       +13 -12    incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/SocketProtocol.java
  
  Index: SocketProtocol.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/SocketProtocol.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SocketProtocol.java	24 Apr 2004 06:29:01 -0000	1.7
  +++ SocketProtocol.java	24 Apr 2004 17:56:32 -0000	1.8
  @@ -240,9 +240,10 @@
               sendBuffer[0].putInt(size);
               sendBuffer[0].flip();
   
  -            log.trace("OP_READ, OP_WRITE " + selectionKey);
  -            selectorManager.setInterestOps(selectionKey, SelectionKey.OP_READ | SelectionKey.OP_WRITE,
0);
  -
  +            // This is non blocking call anyways, push out
  +            // the buffer now if we can.
  +            serviceWrite();
  +            
           } catch (InterruptedException e) {
               log.debug("Communications error, closing connection: ", e);
               close();
  @@ -272,7 +273,11 @@
       private void serviceWrite() {
           log.trace("serviceWrite() triggered.");
           try {
  -
  +        	if( sendBuffer == null ) {
  +                log.trace("Write had allready been serviced.");
  +                return;
  +        	}
  +        	
               long count = socketChannel.write(sendBuffer);
               log.trace("Wrote " + count);
   
  @@ -280,8 +285,8 @@
                   if (sendBuffer[i].hasRemaining()) {
                       // not all was delivered in this call setup selector
                       // so we setup to finish sending async.
  -                    log.trace("OP_READ, OP_WRITE " + selectionKey);
  -                    selectorManager.setInterestOps(selectionKey, SelectionKey.OP_READ |
SelectionKey.OP_WRITE, 0);
  +                    log.trace("OP_WRITE " + selectionKey);
  +                    selectorManager.setInterestOps(selectionKey, SelectionKey.OP_WRITE,
0);
   
                       return;
                   }
  @@ -292,11 +297,7 @@
   
               log.trace("RELEASING " + sendMutex);
               sendMutex.release();
  -            log.trace("RELEASED " + sendMutex);
  -
  -            // We are done writing.
  -            log.trace("OP_READ " + selectionKey);
  -            selectorManager.setInterestOps(selectionKey, SelectionKey.OP_READ, 0);
  +            log.trace("RELEASED " + sendMutex);            
   
           } catch (IOException e) {
               log.debug("Communications error, closing connection: ", e);
  
  
  

Mime
View raw message