# HG changeset patch # User one # Date 1227433132 -32400 # Node ID 7de83b6a34e71f21e1af2804b852750bcb9f31a9 # Parent 149c9a53fc37f9a5a2a448f18d4b1d9d2f2bc1f2 not yet fixed.... diff -r 149c9a53fc37 -r 7de83b6a34e7 rep/handler/Editor.java --- a/rep/handler/Editor.java Sun Nov 23 16:35:20 2008 +0900 +++ b/rep/handler/Editor.java Sun Nov 23 18:38:52 2008 +0900 @@ -47,6 +47,7 @@ // Second Phase が終わって同期が終了。 return; } + if (waitingRequired(command)) return; checkReturnedCommand(command); return; } @@ -70,52 +71,41 @@ // これは、distributed case では、うまくいかないので、送り先のforwarder で処理する。 if (next.isDirect()) { REPCommand keep; - switch (command.cmd) { - case REPCMD_INSERT: - keep = new REPCommand(command); - keep.cmd = REP.REPCMD_INSERT_ACK; - sentList.add(keep); - ServerMainLoop.logger.writeLog("Editor eid:"+eid+" sentList = "+sentList); - break; - case REPCMD_DELETE: - keep = new REPCommand(command); - keep.cmd = REP.REPCMD_DELETE_ACK; - sentList.add(keep); - ServerMainLoop.logger.writeLog("Editor eid:"+eid+" sentList = "+sentList); - break; - } + if (waitingRequired(command)) return; + keep = new REPCommand(command); + sentList.add(keep); + ServerMainLoop.logger.writeLog("Editor eid:"+eid+" sentList = "+sentList); ((Editor) next).checkReturnedCommand(command); } else next.send(command); } else { //他のエディタからの編集コマンド - if (manager.hasWaitingCommand(channel)) { - // We cannot do this operation before watingCommandQueue. - manager.addWaitingCommand(new PacketSet(channel, this, command)); - } else if (isMerging()) { - manager.addWaitingCommand(new PacketSet(getChannel(), this, new REPCommand(command))); - } else { - translator.transReceiveCmd(next,command); - if(command.cmd==REP.REPCMD_DELETE) { - // delete のundo用の文字列は、外に出す意味はない - command.string=null; - } - sendEditorCommand(command); + if (waitingRequired(command)) return; + translator.transReceiveCmd(next,command); + if(command.cmd==REP.REPCMD_DELETE) { + // delete のundo用の文字列は、外に出す意味はない + command.string=null; } + sendEditorCommand(command); } return; } + + private boolean waitingRequired(REPCommand command) { + if (manager.hasWaitingCommand(channel)) { + // We cannot do this operation before watingCommandQueue. + manager.addWaitingCommand(new PacketSet(channel, this, command)); + return true; + } else if (isMerging()) { + manager.addWaitingCommand(new PacketSet(getChannel(), this, new REPCommand(command))); + return true; + } + ServerMainLoop.logger.writeLog("Editor eid:"+eid+" no waiting"); + return false; + } private void sendEditorCommand(REPCommand command) { REPCommand keep = new REPCommand(command); - switch(command.cmd) { - case REPCMD_INSERT: - keep.cmd = REP.REPCMD_INSERT_ACK; - break; - case REPCMD_DELETE: - keep.cmd = REP.REPCMD_DELETE_ACK; - break; - } sentList.add(keep); ServerMainLoop.logger.writeLog("Editor eid:"+eid+" sentList = "+sentList); assert(sentList.size()