summaryrefslogtreecommitdiff
path: root/gnu/java/nio/SelectorProviderImpl.java
diff options
context:
space:
mode:
authorCasey Marshall <csm@gnu.org>2006-09-20 21:39:41 +0000
committerCasey Marshall <csm@gnu.org>2006-09-20 21:39:41 +0000
commita67151b3017805e1d027f1b170777106a5804f60 (patch)
tree54ea95163787f564dd7e74bc0bb457e15629354d /gnu/java/nio/SelectorProviderImpl.java
parent084a2d68af18443b005a1c50a20edb588d1155cb (diff)
downloadclasspath-a67151b3017805e1d027f1b170777106a5804f60.tar.gz
2006-09-20 Casey Marshall <csm@gnu.org>
* configure.ac (AC_CHECK_HEADERS): check for `sys/epoll.h.' (AC_CHECK_FUNCS): check for `epoll_create.' * gnu/java/nio/EpollSelectionKeyImpl.java: new file. * gnu/java/nio/EpollSelectorImpl.java: new file. * gnu/java/nio/SelectorProviderImpl.java (epoll_failed): new class field. (openSelector): return epoll selector if requested and available. * include/Makefile.am (H_FILES): add gnu_java_nio_EpollSelectorImpl.h. (gnu_java_nio_EpollSelectorImpl.h): new target. * include/gnu_java_nio_EpollSelectorImpl.h: new file. * native/jni/java-nio/Makefile.am (libjavanio_la_SOURCES): add gnu_java_nio_EpollSelectorImpl.c. * native/jni/java-nio/gnu_java_nio_EpollSelectorImpl.c: new file.
Diffstat (limited to 'gnu/java/nio/SelectorProviderImpl.java')
-rw-r--r--gnu/java/nio/SelectorProviderImpl.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/gnu/java/nio/SelectorProviderImpl.java b/gnu/java/nio/SelectorProviderImpl.java
index a9a122570..56167b69e 100644
--- a/gnu/java/nio/SelectorProviderImpl.java
+++ b/gnu/java/nio/SelectorProviderImpl.java
@@ -53,6 +53,7 @@ public class SelectorProviderImpl extends SelectorProvider
private static final String SELECTOR_IMPL_KQUEUE = "kqueue";
private static final String SELECTOR_IMPL_EPOLL = "epoll";
private static final String SELECTOR_IMPL = "gnu.java.nio.selectorImpl";
+ private static boolean epoll_failed = false;
public SelectorProviderImpl ()
{
@@ -76,12 +77,31 @@ public class SelectorProviderImpl extends SelectorProvider
String selectorImpl = "default";
if (KqueueSelectorImpl.kqueue_supported())
selectorImpl = SELECTOR_IMPL_KQUEUE;
+ if (EpollSelectorImpl.epoll_supported() && !epoll_failed)
+ selectorImpl = SELECTOR_IMPL_EPOLL;
selectorImpl = SystemProperties.getProperty(SELECTOR_IMPL, selectorImpl);
if (selectorImpl.equals(SELECTOR_IMPL_KQUEUE))
return new KqueueSelectorImpl(this);
+
if (selectorImpl.equals(SELECTOR_IMPL_EPOLL))
- throw new UnsupportedOperationException("epoll selector not yet implemented");
+ {
+ // We jump through these hoops because even though epoll may look
+ // like it's available (sys/epoll.h exists, and you can link against
+ // all the epoll functions) it may not be available in the kernel
+ // (especially 2.4 kernels), meaning you will get ENOSYS at run time.
+ //
+ // Madness!
+ try
+ {
+ return new EpollSelectorImpl(this);
+ }
+ catch (InternalError e)
+ {
+ // epoll_create throws this on ENOSYS.
+ epoll_failed = true;
+ }
+ }
return new SelectorImpl (this);
}