Mercurial > hg > RemoteEditor > REPSessionManager
changeset 318:dc57e24ea3df
*** empty log message ***
author | kono |
---|---|
date | Wed, 08 Oct 2008 10:09:02 +0900 |
parents | c83a3faec487 |
children | dfed28488274 |
files | rep/Editor.java rep/Forwarder.java rep/Session.java rep/SessionManager.java test/sematest/TestEditor.java |
diffstat | 5 files changed, 34 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/Editor.java Tue Oct 07 21:48:31 2008 +0900 +++ b/rep/Editor.java Wed Oct 08 10:09:02 2008 +0900 @@ -21,6 +21,7 @@ private REPCommandOptimizer optimizer; //private REPCommand quit2 = null; private SessionManager manager; + private REPCommand quit2=null; public Editor(SessionManager manager,boolean doOptimize,int editorNo){ super(manager); @@ -91,6 +92,10 @@ if(sentList.size() > 0){ if(sentList.get(0).seq == command.seq){ sentList.remove(0); + if (quit2!=null&&sentList.size()==0) { + send(quit2); + manager.remove(this); + } return true; }else{ System.err.println("Editor.checkReturnedCommand() : command = " + command); @@ -100,11 +105,14 @@ return false; } - - - public void setQuit2(REPCommand cmd) { - //quit2 = cmd; + if (sentList.size()==0) { + send(cmd); + manager.remove(this); + } + // do not send quit2 until we received all pending + // command + quit2 = cmd; } private void setHostAndPort(REPSocketChannel<REPCommand> myChannel2) {
--- a/rep/Forwarder.java Tue Oct 07 21:48:31 2008 +0900 +++ b/rep/Forwarder.java Wed Oct 08 10:09:02 2008 +0900 @@ -25,6 +25,7 @@ } public void send(REPCommand command) { + assert(command!=null); manager.addWriteQueue(new PacketSet(myChannel, null, command)); } @@ -36,4 +37,8 @@ myChannel = channel; } + public void setQuit2(REPCommand cmd) { + send(cmd); + } + } \ No newline at end of file
--- a/rep/Session.java Tue Oct 07 21:48:31 2008 +0900 +++ b/rep/Session.java Wed Oct 08 10:09:02 2008 +0900 @@ -128,4 +128,7 @@ if (f==null) return next; return f; } + public boolean deleteForwarder(Forwarder editor) { + return editorList.remove(editor); + } }
--- a/rep/SessionManager.java Tue Oct 07 21:48:31 2008 +0900 +++ b/rep/SessionManager.java Wed Oct 08 10:09:02 2008 +0900 @@ -467,7 +467,11 @@ { Session session = getSession(receivedCommand.sid); if (session==null) throw new IOException(); - Editor editor = session.getEditor(channel); + Forwarder me = session.getEditor(channel); + if (me==null) break; // already removed. + Forwarder editor = session.getNextEditor(me); + // don't send quit2 to the editor until all pending + // merge is processed. editor.setQuit2(receivedCommand); break; } @@ -652,4 +656,12 @@ writeQueue.add(packetSet); } + + public void remove(Editor editor) { + for(Session s:sessionList) { + s.deleteForwarder(editor); + } + //assert(false); + } + }
--- a/test/sematest/TestEditor.java Tue Oct 07 21:48:31 2008 +0900 +++ b/test/sematest/TestEditor.java Wed Oct 08 10:09:02 2008 +0900 @@ -254,12 +254,12 @@ inputLock = false; break; case SMCMD_QUIT : - if(true) return; if (cmd.eid!=eid) forwardCommand(cmd); else sendCommand(new REPCommand(REP.SMCMD_QUIT_2, sid, eid, seq, 0, "")); + // stop input processing after this command cmds.clear(); break; case SMCMD_QUIT_ACK :