]> source.dussan.org Git - tigervnc.git/commitdiff
pass correct timeout value to selector. limit pixel depth to 24 (OS X defaults to...
authorBrian Hinz <bphinz@users.sourceforge.net>
Wed, 14 Mar 2012 04:15:17 +0000 (04:15 +0000)
committerBrian Hinz <bphinz@users.sourceforge.net>
Wed, 14 Mar 2012 04:15:17 +0000 (04:15 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4867 3789f03b-4d11-0410-bbf8-ca57d06f2519

java/com/tigervnc/network/SocketDescriptor.java
java/com/tigervnc/rdr/FdInStream.java
java/com/tigervnc/rdr/FdOutStream.java
java/com/tigervnc/vncviewer/PixelBufferImage.java

index 2a4c6d815ebcf5a92de520e54566fd71b35364e7..cb4781272796b27ce174f9aa8b81dd1c19081ff6 100644 (file)
@@ -83,10 +83,16 @@ public class SocketDescriptor extends SocketChannel
   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()) {
index 245a6340496799b3c630d5bf5bf1846b7d08e602..ea81388fed1bff7fdc2e56fc277938c308e89dc9 100644 (file)
@@ -136,7 +136,7 @@ public class FdInStream extends InStream {
 
   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 @@ public class FdInStream extends InStream {
       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());
       }
index d2e95ea01b59064f90ccb62e93f973a1dd4c6069..c776724521769a3efebd8b2701574245b245f853 100644 (file)
@@ -24,7 +24,7 @@ import java.nio.channels.SelectionKey;
 
 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 @@ public class FdOutStream extends OutStream {
         }
 
         // Proper timeout
-        //throw TimedOut();
+        throw new TimedOut();
       }
 
       sentUpTo += n;
@@ -93,19 +93,19 @@ public class FdOutStream extends OutStream {
 
   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 @@ public class FdOutStream extends OutStream {
     try {
       n = fd.write(data, dataPtr, length);
     } catch (java.lang.Exception e) {
-      System.out.println("read:"+e.toString());
       throw new Exception(e.toString());
     }
     
index 5f666487f5d9ff1af97bdc0e6a2aba563d2b9bba..e77f460e12bc9f6109c35eb0ef4802c6fd63209f 100644 (file)
@@ -74,7 +74,7 @@ public class PixelBufferImage extends PixelBuffer
     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);