changeset 88:a719aa609e14

add name valuer threads.
author oc
date Thu, 01 May 2014 19:12:05 +0900
parents 9a485070f831
children 1503a373ab73
files src/main/java/jp/ac/u_ryukyu/treevnc/AcceptThread.java src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java src/main/java/jp/ac/u_ryukyu/treevnc/client/GetHostClient.java src/main/java/jp/ac/u_ryukyu/treevnc/server/RequestScreenThread.java src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java
diffstat 5 files changed, 29 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/AcceptThread.java	Thu May 01 18:04:39 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/AcceptThread.java	Thu May 01 19:12:05 2014 +0900
@@ -11,7 +11,6 @@
         public MyRfbProto rfb = null;
         byte[] imageBytes;
         int port;
-        public boolean flag = false;
         
         public AcceptThread(MyRfbProto _rfb) {
                 rfb = _rfb;
@@ -33,32 +32,12 @@
 		while (true) {
 			try {
 				Socket newCli = rfb.accept();
-				if(flag) throw new IOException();
 				OutputStream os = newCli.getOutputStream();
 				InputStream is = newCli.getInputStream();
-//				if(confirmHalt(is)) break;
 				rfb.newClient(this, newCli, new Writer(os), new Reader(is));
 			} catch (IOException e) {
 				break;
 			}
 		}
 	}
-	
-
-	
-	
-	/**
-	 * Instruction stop if you come from if WaitReply.
-	 * @return if return true. This Thread halt.
-	 */
-	/*
-	private boolean confirmHalt(InputStream is) throws IOException {
-		byte[] b = new byte[4];
-		is.mark(4);
-		is.read(b);
-		if(String.valueOf(b).equals("halt")) return true;
-		is.reset();
-		return false;
-	}
-	*/
 }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java	Thu May 01 18:04:39 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java	Thu May 01 19:12:05 2014 +0900
@@ -89,7 +89,7 @@
 				}
 			}
 		};
-		new Thread(timer).start();
+		new Thread(timer, "timer-discard-multicastqueue").start();
 		/**
 		 * discard all incoming from clients
 		 */
@@ -127,7 +127,6 @@
 				writerRunning.set(1);
 				try {
 					requestThreadNotify();
-					// rThread.checkDelay();
 
 					/**
 					 * initial connection of RFB protocol
@@ -140,8 +139,8 @@
 					sendSecResult(os);
 					readClientInit(is);
 					sendInitData(os);
-					new Thread(reader).start(); // discard incoming packet here
-												// after.
+					// after this, we discard upward packet.
+					new Thread(reader, "discard-upward-comm").start(); 
 					// writeFramebufferUpdateRequest(0,0, framebufferWidth,
 					// framebufferHeight, false );
 					for (;;) {
@@ -187,11 +186,11 @@
 			}
 		};
 		clients++;
-		new Thread(sender).start();
+		new Thread(sender, "writer-to-lower-node").start();
 
 	}
 	
-	public synchronized void requestThreadNotify() {
+	public void requestThreadNotify() {
 		rThread.reStart();
 	}
 	
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/GetHostClient.java	Thu May 01 18:04:39 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/GetHostClient.java	Thu May 01 19:12:05 2014 +0900
@@ -135,7 +135,13 @@
         this.stopFlag = stopFlag;
         
     }
-    
+   
+    /**
+     * the thread is waiting accept system call,
+     * close the socket causes exception,
+     * which will terminated the thread.
+     * 
+     */
     public void interrupt() {
     	stopFlag = true;
 		try {
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/RequestScreenThread.java	Thu May 01 18:04:39 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/RequestScreenThread.java	Thu May 01 19:12:05 2014 +0900
@@ -12,10 +12,22 @@
 		rfb = _rfb;
 	}
 
+	
+
+	/* (non-Javadoc)
+	 * @see java.lang.Runnable#run()
+	 * 
+	 * request full screen update every 3 second.
+	 * restart send this immediately.
+	 * nobody call this.
+	 * 
+	 */
 	public void run() {
 		while (true) {
 			try {
-				waitThread();
+				synchronized(this) {
+					wait();
+				}
 				Thread.sleep(3000);
 				rfb.writeFramebufferUpdateRequest(0, 0, protocol.getFbWidth(),
 						protocol.getFbHeight(), false);
@@ -27,14 +39,10 @@
 		}
 	}
 	
-    public synchronized void waitThread() {
-    	try{
-    		wait();
-        }catch(InterruptedException e) {
-        	e.printStackTrace();
-    	}
-    }
 
+    /**
+     * do nothing.
+     */
     public synchronized void reStart() {
     	notify();
     }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java	Thu May 01 18:04:39 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java	Thu May 01 19:12:05 2014 +0900
@@ -99,7 +99,7 @@
 		Thread thread;
 		opendPort = myRfb.selectPort(5999);
 		acceptThread = new AcceptThread(myRfb, opendPort);
-		thread = new Thread(acceptThread);
+		thread = new Thread(acceptThread, "TreeVNC-accept");
 		thread.start();
 		if(firstTime) {
 			getCast = new GetBroadCastProxy(this,