From 956ac1dd1c3adbdae11d91671342381b75669591 Mon Sep 17 00:00:00 2001 From: Brian Hinz Date: Thu, 15 Mar 2012 02:57:52 +0000 Subject: 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 --- java/com/tigervnc/network/SocketDescriptor.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'java') 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); -- cgit v1.2.3