pass correct timeout value to selector. limit pixel depth to 24 (OS X defaults to 32). Increase write buffer size to match CXX value.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4867 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/com/tigervnc/network/SocketDescriptor.java b/java/com/tigervnc/network/SocketDescriptor.java
index 2a4c6d8..cb47812 100644
--- a/java/com/tigervnc/network/SocketDescriptor.java
+++ b/java/com/tigervnc/network/SocketDescriptor.java
@@ -83,10 +83,16 @@
synchronized public int select(int interestOps, int timeout) throws Exception {
int n;
try {
- n = selector.select(timeout);
+ if (timeout == 0) {
+ n = selector.selectNow();
+ } else {
+ n = selector.select(timeout);
+ }
} catch (java.io.IOException e) {
throw new Exception(e.toString());
}
+ if (n == 0)
+ return -1;
Set keys = selector.selectedKeys();
Iterator iter = keys.iterator();
while (iter.hasNext()) {
diff --git a/java/com/tigervnc/rdr/FdInStream.java b/java/com/tigervnc/rdr/FdInStream.java
index 245a634..ea81388 100644
--- a/java/com/tigervnc/rdr/FdInStream.java
+++ b/java/com/tigervnc/rdr/FdInStream.java
@@ -136,7 +136,7 @@
protected int readWithTimeoutOrCallback(byte[] buf, int bufPtr, int len, boolean wait) {
long before = 0;
- long timeout;
+ int timeout;
if (timing)
before = System.nanoTime();
@@ -146,13 +146,13 @@
if (!wait) {
timeout = 0;
} else if (timeoutms != -1) {
- timeout = (long)timeoutms;
+ timeout = timeoutms;
} else {
timeout = 0;
}
try {
- n = fd.select(SelectionKey.OP_READ, timeoutms);
+ n = fd.select(SelectionKey.OP_READ, timeout);
} catch (Exception e) {
throw new SystemException("select:"+e.toString());
}
diff --git a/java/com/tigervnc/rdr/FdOutStream.java b/java/com/tigervnc/rdr/FdOutStream.java
index d2e95ea..c776724 100644
--- a/java/com/tigervnc/rdr/FdOutStream.java
+++ b/java/com/tigervnc/rdr/FdOutStream.java
@@ -24,7 +24,7 @@
public class FdOutStream extends OutStream {
- static final int defaultBufSize = 8192;
+ static final int defaultBufSize = 16384;
static final int minBulkSize = 1024;
public FdOutStream(FileDescriptor fd_, boolean blocking_, int timeoutms_, int bufSize_)
@@ -79,7 +79,7 @@
}
// Proper timeout
- //throw TimedOut();
+ throw new TimedOut();
}
sentUpTo += n;
@@ -93,19 +93,19 @@
private int writeWithTimeout(byte[] data, int dataPtr, int length, int timeoutms)
{
- long timeout;
+ int timeout;
int n;
do {
if (timeoutms != -1) {
- timeout = (long)timeoutms;
+ timeout = timeoutms;
} else {
timeout = 0;
}
try {
- n = fd.select(SelectionKey.OP_WRITE, timeoutms);
+ n = fd.select(SelectionKey.OP_WRITE, timeout);
} catch (java.lang.Exception e) {
System.out.println(e.toString());
throw new Exception(e.toString());
@@ -116,7 +116,6 @@
try {
n = fd.write(data, dataPtr, length);
} catch (java.lang.Exception e) {
- System.out.println("read:"+e.toString());
throw new Exception(e.toString());
}
diff --git a/java/com/tigervnc/vncviewer/PixelBufferImage.java b/java/com/tigervnc/vncviewer/PixelBufferImage.java
index 5f66648..e77f460 100644
--- a/java/com/tigervnc/vncviewer/PixelBufferImage.java
+++ b/java/com/tigervnc/vncviewer/PixelBufferImage.java
@@ -74,7 +74,7 @@
PixelFormat pf;
cm = tk.getColorModel();
if (cm.getColorSpace().getType() == java.awt.color.ColorSpace.TYPE_RGB) {
- int depth = cm.getPixelSize();
+ int depth = ((cm.getPixelSize() > 24) ? 24 : cm.getPixelSize());
int bpp = (depth > 16 ? 32 : (depth > 8 ? 16 : 8));
ByteOrder byteOrder = ByteOrder.nativeOrder();
boolean bigEndian = (byteOrder == ByteOrder.BIG_ENDIAN ? true : false);