You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/06/23 08:24:09 UTC

svn commit: r1138744 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/io/ java/org/apache/commons/runtime/net/ native/ native/include/acr/ native/os/unix/

Author: mturk
Date: Thu Jun 23 06:24:09 2011
New Revision: 1138744

URL: http://svn.apache.org/viewvc?rev=1138744&view=rev
Log:
Split pollset.c to two files

Added:
    commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c
      - copied, changed from r1135690, commons/sandbox/runtime/trunk/src/main/native/os/unix/selector.c
Removed:
    commons/sandbox/runtime/trunk/src/main/native/os/unix/selector.c
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Descriptor.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketSelectorFactory.java
    commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in
    commons/sandbox/runtime/trunk/src/main/native/include/acr/netdefs.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Descriptor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Descriptor.java?rev=1138744&r1=1138743&r2=1138744&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Descriptor.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Descriptor.java Thu Jun 23 06:24:09 2011
@@ -180,7 +180,7 @@ public abstract class Descriptor impleme
     @Override
     public String toString()
     {
-        if (fd >= 0) {
+        if (fd != 0L) {
             return "#" + Utils.hex(fd);
         }
         else {

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=1138744&r1=1138743&r2=1138744&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 Thu Jun 23 06:24:09 2011
@@ -58,8 +58,12 @@ final class SocketSelectorFactory
         if (size < 1 || size > MAX_CAPACITY)
             throw new InvalidRangeException(Local.sm.get("selector.ERANGE"));
         switch (type) {
-            case 0:
+            case 0:     // Posix select
+            case 1:     // Posix poll
                 return new PosixSelector(size);
+            case 2:     // Linux epoll
+            case 3:     // Solaris /dev/poll
+            case 4:     // BSD Kqueue
             default:
                 throw new RuntimeException(Local.sm.get("selector.ETYPE"));
         }

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in?rev=1138744&r1=1138743&r2=1138744&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in Thu Jun 23 06:24:09 2011
@@ -67,10 +67,11 @@ UNIX_SOURCES=\
 	$(TOPDIR)/os/unix/init.c \
 	$(TOPDIR)/os/unix/platform.c \
 	$(TOPDIR)/os/unix/poll.c \
+	$(TOPDIR)/os/unix/pollset.c \
 	$(TOPDIR)/os/unix/posixapi.c \
 	$(TOPDIR)/os/unix/procmutex.c \
 	$(TOPDIR)/os/unix/shmem.c \
-	$(TOPDIR)/os/unix/selector.c \
+	$(TOPDIR)/os/unix/select.c \
 	$(TOPDIR)/os/unix/semaphore.c \
 	$(TOPDIR)/os/unix/time.c \
 	$(TOPDIR)/os/unix/usock.c \

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/netdefs.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/netdefs.h?rev=1138744&r1=1138743&r2=1138744&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/netdefs.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/netdefs.h Thu Jun 23 06:24:09 2011
@@ -60,4 +60,12 @@
 #define ACR_IPV4_ADDR_OK  0x01
 #define ACR_IPV6_ADDR_OK  0x02
 
+/** Selector implementation types */
+#define ACR_PS_TYPE_SELECT         0
+#define ACR_PS_TYPE_POLL           1
+#define ACR_PS_TYPE_EPOLL          2
+#define ACR_PS_TYPE_DEVPOLL        3
+#define ACR_PS_TYPE_KQUEUE         4
+
+
 #endif /* _ACR_IODEFS_H */

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h?rev=1138744&r1=1138743&r2=1138744&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h Thu Jun 23 06:24:09 2011
@@ -137,13 +137,8 @@ typedef struct stat         struct_stat_
 
 #endif /* F_DUPFD */
 
-#define  PS_TYPE_POLL           0
-#define  PS_TYPE_EPOLL          1
-#define  PS_TYPE_DEVPOLL        2
-#define  PS_TYPE_KQUEUE         3
-
 #if 1
-# define PS_DEFAULT_TYPE        PS_TYPE_POLL
+# define PS_DEFAULT_TYPE        ACR_PS_TYPE_POLL
 #else
 #endif
 

Copied: commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c (from r1135690, commons/sandbox/runtime/trunk/src/main/native/os/unix/selector.c)
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c?p2=commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c&p1=commons/sandbox/runtime/trunk/src/main/native/os/unix/selector.c&r1=1135690&r2=1138744&rev=1138744&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/selector.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c Thu Jun 23 06:24:09 2011
@@ -23,9 +23,6 @@
 #include "acr/netapi.h"
 #include "arch_opts.h"
 #include <poll.h>
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
 
 /* pollset operation states */
 #define PSS_DESTROY     1
@@ -88,44 +85,6 @@ static short reventt(short event)
     return rv;
 }
 
-ACR_NET_EXPORT(jint, SocketSelectorFactory, type0)(JNI_STDARGS)
-{
-    return PS_DEFAULT_TYPE;
-}
-
-ACR_NET_EXPORT(jint, LocalSelectorFactory, type0)(JNI_STDARGS)
-{
-    return PS_DEFAULT_LOCAL;
-}
-
-static int rlimit_nofile(void)
-{
-    int nm = 65536;
-#if HAVE_SYS_RESOURCE_H
-    struct rlimit rl;
-
-    if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && rl.rlim_max != RLIM_INFINITY)
-        nm = (int)rl.rlim_max;
-    else
-#endif
-        nm = (int)sysconf(_SC_OPEN_MAX);
-    if (nm > 1)
-        --nm;
-    else
-        nm = 1023;
-    return nm;
-}
-
-ACR_NET_EXPORT(jint, SocketSelectorFactory, size0)(JNI_STDARGS)
-{
-    return rlimit_nofile();
-}
-
-ACR_NET_EXPORT(jint, LocalSelectorFactory, size0)(JNI_STDARGS)
-{
-    return rlimit_nofile();
-}
-
 ACR_NET_EXPORT(jlong, PosixSelector, create0)(JNI_STDARGS, jint size)
 {
     int rc;