commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1129030 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/net/ java/org/apache/commons/runtime/platform/unix/ native/include/acr/ native/os/unix/
Date Mon, 30 May 2011 07:38:24 GMT
Author: mturk
Date: Mon May 30 07:38:23 2011
New Revision: 1129030

URL: http://svn.apache.org/viewvc?rev=1129030&view=rev
Log:
Add separate SelectionOp flags

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionOp.java
  (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalSocketSelectorFactory.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalStrings.properties
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionKey.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketSelectorFactory.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SocketSelectorImpl.java
    commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalSocketSelectorFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalSocketSelectorFactory.java?rev=1129030&r1=1129029&r2=1129030&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalSocketSelectorFactory.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalSocketSelectorFactory.java
Mon May 30 07:38:23 2011
@@ -55,7 +55,7 @@ public final class LocalSocketSelectorFa
         throws InvalidRangeException, OutOfMemoryError
     {
         if (size < 1 || size > MAX_CAPACITY)
-            throw new InvalidRangeException();
+            throw new InvalidRangeException(Local.sm.get("selector.ERANGE"));
         return new0(size);
     }
 

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalStrings.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalStrings.properties?rev=1129030&r1=1129029&r2=1129030&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalStrings.properties
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalStrings.properties
Mon May 30 07:38:23 2011
@@ -15,4 +15,5 @@
 addr.EHOSTNAME=Invalid hostname
 port.ERANGE=Port is outside allowed range
 socketd.CLOSED=Socket is already closed
-selector.NULL=Sellector can't be null
\ No newline at end of file
+selector.NULL=Selector can't be null
+selector.ERANGE=Selector size is outsize allowed range

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java?rev=1129030&r1=1129029&r2=1129030&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java Mon
May 30 07:38:23 2011
@@ -35,37 +35,37 @@ public final class Poll
     /**
      * There is data to read
      */
-    public static final short     POLLIN        = SelectionKey.OP_READ;
+    public static final short     POLLIN        = SelectionOp.READ;
     /**
      * There is urgent data to read.
      * e.g., out-of-band data on TCP socket; pseudo-terminal master in  packet  mode
      * has seen state change in slave.
      */
-    public static final short     POLLPRI       = SelectionKey.OP_PRI;
+    public static final short     POLLPRI       = SelectionOp.PRI;
     /**
      * Writing now will not block.
      */
-    public static final short     POLLOUT       = SelectionKey.OP_WRITE;
+    public static final short     POLLOUT       = SelectionOp.WRITE;
     /**
      * A Stream socket peer closed  connection, or shut down writing half of connection.
      */
-    public static final short     POLLRDHUP     = SelectionKey.OP_RDHUP;
+    public static final short     POLLRDHUP     = SelectionOp.RDHUP;
     /**
      * A stream-oriented connection was either diconnected or aborted.
      */
-    public static final short     POLLHUP       = SelectionKey.OP_HANGUP;
+    public static final short     POLLHUP       = SelectionOp.HANGUP;
     /**
-     * An invalid descriptor was used.
+     * An error has occurred.
      */
-    public static final short     POLLNVAL      = SelectionKey.OP_ERROR;
+    public static final short     POLLERR       = SelectionOp.ERROR;
     /**
-     * An error has occurred.
+     * An invalid descriptor was used.
      */
-    public static final short     POLLERR       = SelectionKey.OP_ERROR;
+    public static final short     POLLNVAL      = SelectionOp.NVAL;
     /**
      * Time-To-Live event occurred.
      */
-    public static final short     POLLTTL       = SelectionKey.OP_TIMEOUT;
+    public static final short     POLLTTL       = SelectionOp.TIMEOUT;
 
 
     private static native int wait0(int[] fds, short[] events, short[] revents,

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionKey.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionKey.java?rev=1129030&r1=1129029&r2=1129030&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionKey.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionKey.java
Mon May 30 07:38:23 2011
@@ -31,59 +31,6 @@ public abstract class SelectionKey
     private Endpoint        endpoint;
     private int             timeout;
 
-    /** Accept operation.
-     * <p>
-     * </p>
-     */
-    static final int OP_ACCEPT          = 0x0001;
-    /** Connect operation.
-     * <p>
-     * </p>
-     */
-    static final int OP_CONNECT         = 0x0002;
-    /** Read operation.
-     * <p>
-     * </p>
-     */
-    static final int OP_READ            = 0x0004;
-    /** Write operation.
-     * <p>
-     * </p>
-     */
-    static final int OP_PRI             = 0x0008;
-    /** Write operation.
-     * <p>
-     * </p>
-     */
-    static final int OP_WRITE           = 0x0010;
-    /** Read hang up operation.
-     * <p>
-     * If present in output it signals that
-     * stream socket peer closed connection,
-     * or shut down writing half of connection.
-     * </p>
-     */
-    static final int OP_RDHUP           = 0x0020;
-    /** Hang up happened on the associated descriptor.
-     * <p>
-     * This is output only flag.
-     * </p>
-     */
-    static final int OP_HANGUP          = 0x0040;
-    /** Error condition happened on the associated descriptor.
-     * <p>
-     * This is output only flag.
-     * </p>
-     */
-    static final int OP_ERROR           = 0x0100;
-    /** Timeout condition happened on the associated descriptor.
-     * <p>
-     * This is output only flag and indicates that Time-To-Live
-     * event occurred.
-     * </p>
-     */
-    static final int OP_TIMEOUT         = 0x0200;
-
     /**
      * Constructs a new {@code SelectionKey} for given selector and enpoint
      */

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionOp.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionOp.java?rev=1129030&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionOp.java
(added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionOp.java
Mon May 30 07:38:23 2011
@@ -0,0 +1,90 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.net;
+
+/**
+ * Selection operation type flags.
+ */
+public final class SelectionOp
+{
+
+    private SelectionOp()
+    {
+        // No Instance
+    }
+
+    /** Accept operation.
+     * <p>
+     * </p>
+     */
+    public static final int ACCEPT      = 0x0001;
+    /** Connect operation.
+     * <p>
+     * </p>
+     */
+    public static final int CONNECT     = 0x0002;
+    /** Read operation.
+     * <p>
+     * </p>
+     */
+    public static final int READ        = 0x0004;
+    /** There is urgent data to read.
+     * <p>
+     * </p>
+     */
+    public static final int PRI         = 0x0008;
+    /** Write operation.
+     * <p>
+     * </p>
+     */
+    public static final int WRITE       = 0x0010;
+    /** Read hang up operation.
+     * <p>
+     * If present in output it signals that
+     * stream socket peer closed connection,
+     * or shut down writing half of connection.
+     * </p>
+     */
+    public static final int RDHUP       = 0x0020;
+    /** Hang up happened on the associated descriptor.
+     * <p>
+     * This is output only flag.
+     * </p>
+     */
+    public static final int HANGUP      = 0x0040;
+    /** Error condition happened on the associated descriptor.
+     * <p>
+     * This is output only flag.
+     * </p>
+     */
+    public static final int ERROR       = 0x0100;
+    /**
+     * An invalid descriptor was used.
+     * <p>
+     * This is output only flag.
+     * </p>
+     */
+    public static final int NVAL        = 0x0200;
+    /** Timeout condition happened on the associated descriptor.
+     * <p>
+     * This is output only flag and indicates that Time-To-Live
+     * event occurred.
+     * </p>
+     */
+    public static final int TIMEOUT     = 0x0400;
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionOp.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketSelectorFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketSelectorFactory.java?rev=1129030&r1=1129029&r2=1129030&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketSelectorFactory.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketSelectorFactory.java
Mon May 30 07:38:23 2011
@@ -55,7 +55,7 @@ public final class SocketSelectorFactory
         throws InvalidRangeException, OutOfMemoryError
     {
         if (size < 1 || size > MAX_CAPACITY)
-            throw new InvalidRangeException();
+            throw new InvalidRangeException(Local.sm.get("selector.ERANGE"));
         return new0(size);
     }
 

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SocketSelectorImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SocketSelectorImpl.java?rev=1129030&r1=1129029&r2=1129030&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SocketSelectorImpl.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SocketSelectorImpl.java
Mon May 30 07:38:23 2011
@@ -24,6 +24,7 @@ import org.apache.commons.runtime.net.En
 import org.apache.commons.runtime.net.IllegalSelectorException;
 import org.apache.commons.runtime.net.Poll;
 import org.apache.commons.runtime.net.SelectionKey;
+import org.apache.commons.runtime.net.SelectionOp;
 import org.apache.commons.runtime.net.Selector;
 import org.apache.commons.runtime.AlreadyExistsException;
 import org.apache.commons.runtime.InvalidArgumentException;

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h?rev=1129030&r1=1129029&r2=1129030&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h Mon May 30 07:38:23
2011
@@ -35,15 +35,6 @@
 #define ACR_FOPEN_NOINHERIT  0x010000  /**< Do not inherit files on exec */
 #define ACR_FOPEN_INFO       0x020000  /**< Open without READ or WRITE access */
 
-#define ACR_POLLIN           0x01
-#define ACR_POLLPRI          0x02
-#define ACR_POLLOUT          0x04
-#define ACR_POLLERR          0x08
-#define ACR_POLLHUP          0x10
-#define ACR_POLLRDHUP        0x20
-#define ACR_POLLNVAL         0x40
-#define ACR_POLLTTL          0x80
-
 #define ACR_OP_ACCEPT        0x0001
 #define ACR_OP_CONNECT       0x0002
 #define ACR_OP_READ          0x0004
@@ -53,6 +44,7 @@
 #define ACR_OP_RDHUP         0x0020
 #define ACR_OP_HANGUP        0x0040
 #define ACR_OP_ERROR         0x0100
-#define ACR_OP_TIMEOUT       0x0200
+#define ACR_OP_NVAL          0x0200
+#define ACR_OP_TIMEOUT       0x0400
 
 #endif /* _ACR_IODEFS_H */

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c?rev=1129030&r1=1129029&r2=1129030&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c Mon May 30 07:38:23 2011
@@ -101,7 +101,7 @@ static short reventt(short event)
         rv |= ACR_OP_RDHUP;
 #endif
     if (event & POLLNVAL)
-        rv |= ACR_OP_ERROR;
+        rv |= ACR_OP_NVAL;
     return rv;
 }
 
@@ -436,7 +436,7 @@ ACR_UNX_EXPORT(jint, SocketSelectorImpl,
                 if (ps->ooset[i].exp > now) {
                     /* Expired descriptor */
                     ps->fdset[i].revents = POLLHUP;
-                    pevents[rv] = ACR_POLLTTL;
+                    pevents[rv] = ACR_OP_TIMEOUT;
                     (*env)->SetObjectArrayElement(env, rs, rv++, ps->ooset[i].obj);
                 }
             }



Mime
View raw message