changeset 110:6f95e5efa799

writer living flag
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 05 Aug 2011 12:15:43 +0900
parents 3f73ebf918bd
children 7e60020f0a72
files src/myVncProxy/MyRfbProto.java
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/myVncProxy/MyRfbProto.java	Fri Aug 05 12:08:17 2011 +0900
+++ b/src/myVncProxy/MyRfbProto.java	Fri Aug 05 12:15:43 2011 +0900
@@ -649,9 +649,10 @@
 					try {
 						synchronized(this) {
 							wait(timeout);
+							writerRunning.set(false);
 							while (!writerRunning.get()) {
 								c.poll(); // discard, should be timeout
-								wait(10);
+								wait(10); // if this is too short, writer cannot take the poll, if this is too long, memory will overflow... 
 							}
 						}
 					} catch (InterruptedException e) {
@@ -703,6 +704,7 @@
 							System.out.println("client "+ myId);
 						}
 						writeToClient(os, bufs, inputIndex);
+						writerRunning.set(true);
 					}
 				} catch (IOException e) {
 					try {