diff options
author | Brian Hinz <bphinz@users.sourceforge.net> | 2012-03-15 02:57:52 +0000 |
---|---|---|
committer | Brian Hinz <bphinz@users.sourceforge.net> | 2012-03-15 02:57:52 +0000 |
commit | 956ac1dd1c3adbdae11d91671342381b75669591 (patch) | |
tree | 441b3f500d473572cef153c896ec74b12f9643fc /java/com/tigervnc/network/SocketDescriptor.java | |
parent | 60a2ece48f11349f3e9006cb802d9bed2ded68ee (diff) | |
download | tigervnc-956ac1dd1c3adbdae11d91671342381b75669591.tar.gz tigervnc-956ac1dd1c3adbdae11d91671342381b75669591.zip |
Fix an issue where java viewer appears to hang on Mac OS X. As far as I can tell, this is caused by an upstream bug which might be fixed in JDK 7, but for now this gets around the problem without significantly affecting performance.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4868 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java/com/tigervnc/network/SocketDescriptor.java')
-rw-r--r-- | java/com/tigervnc/network/SocketDescriptor.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/java/com/tigervnc/network/SocketDescriptor.java b/java/com/tigervnc/network/SocketDescriptor.java index cb478127..95ee84ae 100644 --- a/java/com/tigervnc/network/SocketDescriptor.java +++ b/java/com/tigervnc/network/SocketDescriptor.java @@ -34,7 +34,7 @@ public class SocketDescriptor extends SocketChannel implements FileDescriptor { public SocketDescriptor() throws Exception { - super(SelectorProvider.provider()); + super(DefaultSelectorProvider()); try { channel = SocketChannel.open(); channel.configureBlocking(false); @@ -49,6 +49,14 @@ public class SocketDescriptor extends SocketChannel } } + private static SelectorProvider DefaultSelectorProvider() { + // kqueue() selector provider on OS X is not working, fall back to select() for now + String os = System.getProperty("os.name"); + if (os.startsWith("Mac OS X")) + System.setProperty("java.nio.channels.spi.SelectorProvider","sun.nio.ch.PollSelectorProvider"); + return SelectorProvider.provider(); + } + synchronized public int read(byte[] buf, int bufPtr, int length) throws Exception { int n; ByteBuffer b = ByteBuffer.allocate(length); |