# HG changeset patch # User one # Date 1287770180 -32400 # Node ID 16890938847950ccb55ce6c220d2de8c83be95dc # Parent 4aba8ae3125b59942801f7efe13c7751bdea8964 new merge continue diff -r 4aba8ae3125b -r 168909388479 rep/handler/Editor.java --- a/rep/handler/Editor.java Fri Oct 22 11:27:57 2010 +0900 +++ b/rep/handler/Editor.java Sat Oct 23 02:56:20 2010 +0900 @@ -184,6 +184,7 @@ transReceiveCmd(next,command); if (mergeMode==MergeMode.Direct) { sendEditorCommand(command); + // Own commands may enter after here. To distinguish put mark here sentList.addLast(mergeMark ); startMerge(command); } else @@ -201,7 +202,7 @@ sendEditorCommand(command); if (mergeMode==MergeMode.Direct) { ServerMainLoop.logger.writeLog("Editor"+eid+": User Command Before "+command+report()); - truncateSentList(command); + truncateSentList(command,true); ServerMainLoop.logger.writeLog("Editor"+eid+": User Command After "+command+report()); } return; @@ -328,10 +329,11 @@ // 送らないで良い場合もある? REPCommand cmd = new REPCommand(REP.SMCMD_START_MERGE,command.sid,REP.SM_EID.id,seq(),0,""); sendToEditor(cmd); - merging = true; + // merging = true; // Session Manager 側で、このeditorへの他のeditorからの - // 入力を止めて、merge にそなえる。merge は、eidtor 側から - // ACKが来てから始まる。 + // 入力を止めて、merge にそなえるのは、ここでは間に合わないので、 + // send() で行っている。USER Command は、止められないが、問題ない。 + // merge は、eidtor 側からACKが来てから始まる。 } /** @@ -391,9 +393,17 @@ REPCommand mergeEnd = new REPCommand(REP.SMCMD_END_MERGE,sid,eid,seq(),0,""); sendToEditor(mergeEnd); if (mergeMode==MergeMode.Direct) { - REPCommand last = sentList.getLast(); + REPCommand last = sentList.size()==0?null:sentList.getLast(); + ServerMainLoop.logger.writeLog("Editor"+eid+": EndMerge Before"+report()); + LinkedList u = new LinkedList(); + for(REPCommand c: unMergedCmds) { + if (c.cmd==REP.REPCMD_MERGE_MARK) break; + u.addLast(c); + } + unMergedCmds = u; if (last!=null && last.eid==eid && last.sid==sid) - truncateSentList(last); + truncateSentList(last,false); + sentList.remove(mergeMark); preMergeCommand = null; ServerMainLoop.logger.writeLog("Editor"+eid+": EndMerge "+report()); return ; @@ -416,14 +426,19 @@ * User Editor Command Fix the command order of * other editor commands except own command * truncate sentList and unMergedCmds. + *   mode==false Don't truncate unMergedCmds after merge mark */ - private void truncateSentList(REPCommand commit) { + private void truncateSentList(REPCommand commit, boolean mode) { if (merging) return; LinkedListu = new LinkedList(); + boolean flag=true; for(REPCommand command:unMergedCmds) { - if (command.cmd==REP.REPCMD_MERGE_MARK) continue; - if (command.eid!=eid) break; - u.addLast(command); + if (command.cmd==REP.REPCMD_MERGE_MARK) { + flag = mode; + continue; + } + if (command.eid!=eid && command.eid!=REP.MERGE_EID.id) break; + if (flag) u.addLast(command); } unMergedCmds = u; LinkedLists = new LinkedList(); @@ -637,6 +652,7 @@ //マージ中にユーザから割り込みがあった場合 if(isMerging()){ + logger.writeLog("mergeAgain"+eid+":"+cmd); mergeAgain = true; } @@ -738,7 +754,6 @@ editor.sendToEditor(m); } logger.writeLog("OptimizedOutputMerge"+eid+":"+sentMergedList); - merging = true; return true; } @@ -838,6 +853,7 @@ public void mergeAck() { logger.writeLog("Editor"+eid+": START MERGE "+ ((unMergedCmds.size()>0)?" unMergedCmds = "+ unMergedCmds : "")); + // これ以降のUser command の割り込みはmergeのやり直しが必要 merging = true; }