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 DatagramProtocol.java ServerSocketAcceptor.java SocketProtocol.java
Date Sun, 25 Apr 2004 02:03:37 GMT
chirino     2004/04/24 19:03:37

  Modified:    modules/network/src/java/org/apache/geronimo/network
                        SelectorManager.java
               modules/network/src/java/org/apache/geronimo/network/protocol
                        DatagramProtocol.java ServerSocketAcceptor.java
                        SocketProtocol.java
  Log:
  Cleaned up setInterestOpt method calls.
  
  Revision  Changes    Path
  1.6       +15 -6     incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/SelectorManager.java
  
  Index: SelectorManager.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/SelectorManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SelectorManager.java	24 Apr 2004 17:55:02 -0000	1.5
  +++ SelectorManager.java	25 Apr 2004 02:03:37 -0000	1.6
  @@ -144,9 +144,18 @@
                   for (Iterator i = keys.iterator(); i.hasNext();) {
                       final SelectionKey key = (SelectionKey) i.next();
   
  -                    if (key.isReadable())key.interestOps(key.interestOps() & (~SelectionKey.OP_READ));
  -                    if (key.isWritable())key.interestOps(key.interestOps() & (~SelectionKey.OP_WRITE));
  -                    if (key.isAcceptable())key.interestOps(key.interestOps() & (~SelectionKey.OP_ACCEPT));
  +                    if (key.isReadable()) { 
  +                        log.trace("-OP_READ " + key);
  +                        key.interestOps(key.interestOps() & (~SelectionKey.OP_READ));
  +                    }
  +                    if (key.isWritable()) {
  +                        log.trace("-OP_WRITE " + key);
  +                        key.interestOps(key.interestOps() & (~SelectionKey.OP_WRITE));
  +                    }
  +                    if (key.isAcceptable()) {
  +                        log.trace("-OP_ACCEPT " + key);
  +                        key.interestOps(key.interestOps() & (~SelectionKey.OP_ACCEPT));
  +                    }
   
                       threadPool.getWorkManager().execute(new Runnable() {
                           public void run() {
  @@ -180,10 +189,10 @@
           }
       }
   
  -    public void setInterestOps(SelectionKey selectorKey, int setOps, int resetOps) {
  +    public void addInterestOps(SelectionKey selectorKey, int addOpts) {
           synchronized (guard) {
               selector.wakeup();
  -            selectorKey.interestOps((selectorKey.interestOps() & (~resetOps)) | setOps);
  +            selectorKey.interestOps( selectorKey.interestOps() | addOpts );
           }
       }
   
  
  
  
  1.5       +2 -2      incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/DatagramProtocol.java
  
  Index: DatagramProtocol.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/DatagramProtocol.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DatagramProtocol.java	17 Mar 2004 03:11:59 -0000	1.4
  +++ DatagramProtocol.java	25 Apr 2004 02:03:37 -0000	1.5
  @@ -230,7 +230,7 @@
   
               receiveBuffer.clear();
   
  -            selectorManager.setInterestOps(selectionKey, SelectionKey.OP_READ, 0);
  +            selectorManager.addInterestOps(selectionKey, SelectionKey.OP_READ);
           } catch (IOException e) {
               log.debug("Communications error, closing connection: ", e);
               close();
  
  
  
  1.6       +2 -2      incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/ServerSocketAcceptor.java
  
  Index: ServerSocketAcceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/ServerSocketAcceptor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ServerSocketAcceptor.java	19 Apr 2004 16:30:32 -0000	1.5
  +++ ServerSocketAcceptor.java	25 Apr 2004 02:03:37 -0000	1.6
  @@ -171,7 +171,7 @@
                   channel.socket().setTcpNoDelay(enableTcpNoDelay);
                   acceptorListener.accept(channel);
   
  -                selectorManager.setInterestOps(selectionKey, SelectionKey.OP_ACCEPT, 0);
  +                selectorManager.addInterestOps(selectionKey, SelectionKey.OP_ACCEPT);
               } catch (IOException e) {
                   // this should be ok
               }
  
  
  
  1.10      +10 -14    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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SocketProtocol.java	24 Apr 2004 21:34:34 -0000	1.9
  +++ SocketProtocol.java	25 Apr 2004 02:03:37 -0000	1.10
  @@ -188,7 +188,7 @@
           try {
               socketChannel.configureBlocking(false);
               selectionKey = selectorManager.register(socketChannel, SelectionKey.OP_READ,
this);
  -            log.trace("OP_READ " + selectionKey);
  +            log.trace("+OP_READ " + selectionKey);
           } catch (ClosedChannelException e) {
               state = STOPPED;
               throw new ProtocolException(e);
  @@ -241,8 +241,8 @@
               sendBuffer[0].putInt(size);
               sendBuffer[0].flip();
   
  -            log.trace("OP_READ, OP_WRITE " + selectionKey);
  -            selectorManager.setInterestOps(selectionKey, SelectionKey.OP_READ | SelectionKey.OP_WRITE,
0);
  +            log.trace("+OP_WRITE " + selectionKey);
  +            selectorManager.addInterestOps(selectionKey, SelectionKey.OP_WRITE);
   
           } catch (InterruptedException e) {
               log.debug("Communications error, closing connection: ", e);
  @@ -285,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.addInterestOps(selectionKey, SelectionKey.OP_WRITE);
   
                       return;
                   }
  @@ -299,10 +299,6 @@
               sendMutex.release();
               log.trace("RELEASED " + sendMutex);
   
  -
  -            // We are done writing.
  -            log.trace("OP_READ " + selectionKey);
  -            selectorManager.setInterestOps(selectionKey, SelectionKey.OP_READ, 0);
           } catch (IOException e) {
               log.debug("Communications error, closing connection: ", e);
               close();
  @@ -345,8 +341,8 @@
   
                       if (size == 0) {
                           headerBuffer.clear();
  -                        log.trace("OP_READ " + selectionKey);
  -                        selectorManager.setInterestOps(selectionKey, SelectionKey.OP_READ,
0);
  +                        log.trace("+OP_READ " + selectionKey);
  +                        selectorManager.addInterestOps(selectionKey, SelectionKey.OP_READ);
                           return;
                       }
   
  @@ -382,8 +378,8 @@
   
                   }
               }
  -            log.trace("OP_READ " + selectionKey);
  -            selectorManager.setInterestOps(selectionKey, SelectionKey.OP_READ, 0);
  +            log.trace("+OP_READ " + selectionKey);
  +            selectorManager.addInterestOps(selectionKey, SelectionKey.OP_READ);
               if (tracing) log.trace("No more data available to be read.");
   
           } catch (CancelledKeyException e) {
  
  
  

Mime
View raw message