Mercurial > hg > Members > riono > TreeVNC_ja_comment
changeset 186:f76ee760c2d2
dead lock on command line root
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 24 Jun 2014 00:48:26 +0900 |
parents | feefc1e58153 |
children | b62a16548800 |
files | src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java src/viewer_swing/java/com/glavsoft/viewer/Viewer.java src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java |
diffstat | 6 files changed, 41 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java Mon Jun 23 22:31:22 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEESender.java Tue Jun 24 00:48:26 2014 +0900 @@ -34,6 +34,7 @@ } else if (!rfb.getCuiVersion()) { rfb.readSendData(dataLen, reader, null); reader.reset(); + reader.skip(16); decoder.decode(reader, renderer, rect); return; }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Mon Jun 23 22:31:22 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Tue Jun 24 00:48:26 2014 +0900 @@ -56,6 +56,7 @@ private TreeRootFinderListener getCast; private CreateConnectionParam cp; private boolean hasViewer = false; + private boolean reconnecting; public MyRfbProto() { @@ -346,14 +347,19 @@ } - public synchronized void setReadyReconnect(boolean ready) { - readyReconnect = ready; - if (ready) { - notifyAll(); - } + public void setReadyReconnect(boolean ready) { + if (reconnecting) { + sendDesktopSizeChange(id); + reconnecting = false; + } else { + readyReconnect = ready; + if (ready) { + notifyAll(); + } + } } - public synchronized void waitForReady(ViewerInterface vncProxyService) throws InterruptedException { + public synchronized void waitForReady() throws InterruptedException { while (!readyReconnect) { wait(); } @@ -503,7 +509,9 @@ if (header.get(0) == FramebufferUpdate) { int encoding = header.getInt(12); if (encoding == EncodingType.ZRLE.getId() - || encoding == EncodingType.ZLIB.getId()) { // ZRLEE is already compressed + || encoding == EncodingType.ZLIB.getId()) { + // recompress into ZREE + // uncompressed result is remain in bytes ByteBuffer len = multicastqueue.allocate(4); reader.readBytes(len.array(), 0, 4); len.limit(4); @@ -532,7 +540,6 @@ bufs.addFirst(header); addSerialNumber(bufs); multicastqueue.put(bufs); - if (!isRoot()) reader.reset(); } catch (DataFormatException e) { throw new TransportException(e); } catch (IOException e) { @@ -540,6 +547,7 @@ } return; } + // ZRLEE is already compressed bufs.add(header); if (dataLen > 16) { ByteBuffer b = multicastqueue.allocate(dataLen - 16); @@ -612,12 +620,8 @@ // stop reader stop stopReceiverTask(); vncProxyService.inhelitClients(vncProxyService, hostName); - orderRecconection(vncProxyService, hostName, id); - } - - public void orderRecconection(ViewerInterface vncProxyService, String hostName, short id) throws UnknownHostException, IOException, InterruptedException { - waitForReady(vncProxyService); - sendDesktopSizeChange(id); + reconnecting = true; + // after connecting VNC server, rfb send SEND_INIT_DATA command } /** @@ -664,5 +668,9 @@ hasViewer = b; } + public void setReconnecting(boolean b) { + reconnecting = b; + } + }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java Mon Jun 23 22:31:22 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java Tue Jun 24 00:48:26 2014 +0900 @@ -25,7 +25,7 @@ static VncProxyService currentVps; public VncProxyService() { - ProtocolSettings.getDefaultSettings(); + ProtocolSettings.getDefaultSettings(); uiSettings = super.uiSettings; }
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Mon Jun 23 22:31:22 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Tue Jun 24 00:48:26 2014 +0900 @@ -386,6 +386,7 @@ connectionParams.setConnectionParam(hostname, vncport); isApplet = true; settings.setViewOnly(true); // too avoid unnecessary upward traffic + rfb.setReconnecting(true); run(); } @@ -395,6 +396,7 @@ connectionParams.setConnectionParam(hostName, vncport); isApplet = true; myRfbProto.createConnectionAndStart(this); + myRfbProto.setReconnecting(true); run(); } }
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java Mon Jun 23 22:31:22 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingRfbConnectionWorker.java Tue Jun 24 00:48:26 2014 +0900 @@ -26,7 +26,9 @@ import com.glavsoft.exceptions.*; import com.glavsoft.rfb.IPasswordRetriever; +import com.glavsoft.rfb.IRepaintController; import com.glavsoft.rfb.IRfbSessionListener; +import com.glavsoft.rfb.protocol.NullRepaintController; import com.glavsoft.rfb.protocol.Protocol; import com.glavsoft.rfb.protocol.ProtocolSettings; import com.glavsoft.transport.Reader; @@ -118,7 +120,8 @@ if(!myRfb.getCuiVersion()) viewerWindow = viewerWindowFactory.createViewerWindow(workingProtocol, rfbSettings, uiSettings, connectionString, presenter); myRfb.setProtocolContext(workingProtocol); - workingProtocol.startNormalHandling(this, viewerWindow.getSurface(), clipboardController, myRfb); + IRepaintController s = viewerWindow==null? new NullRepaintController() : viewerWindow.getSurface(); + workingProtocol.startNormalHandling(this, s, clipboardController, myRfb); presenter.showMessage("Started"); if (myRfb.hasViewer()) viewerWindow.setVisible(true);
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Mon Jun 23 22:31:22 2014 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Tue Jun 24 00:48:26 2014 +0900 @@ -832,17 +832,17 @@ JButton screenButton = buttonsBar.createButton("share", "Share my screen", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - // before change server, data from previous server - // should be stopped. - viewer.setCuiVersion(true); - if (viewer.getRfb().isRoot()) { - try { - viewer.getRfb().changeVNCServer(viewer, "localhost", 1980, 1090, viewer.getRfb().getId()); - } catch (Exception e1) { - System.out.println("can't change server :" + e1.getMessage()); - } - return; - } + // before change server, data from previous server + // should be stopped. + viewer.setCuiVersion(true); + if (viewer.getRfb().isRoot()) { + try { + viewer.getRfb().changeVNCServer(viewer, "127.0.0.1", 1980, 1090, viewer.getRfb().getId()); + } catch (Exception e1) { + System.out.println("can't change server :" + e1.getMessage()); + } + return; + } String adr = viewer.getRfb().getMyAddress(); context.sendMessage(new ScreenChangeRequest(adr, viewer.getRfb().getId())); }