changeset 444:97593c486db6

blocking in-editor packet/out-editor packet in merging
author one
date Mon, 13 Sep 2010 14:52:11 +0900
parents bd086be276d2
children 22a741c1fa2d
files rep/handler/Editor.java
diffstat 1 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/rep/handler/Editor.java	Mon Sep 13 00:49:34 2010 +0900
+++ b/rep/handler/Editor.java	Mon Sep 13 14:52:11 2010 +0900
@@ -82,7 +82,7 @@
 		switch(command.cmd) {
 		case REPCMD_INSERT_ACK:
 		case REPCMD_DELETE_ACK:
-			// if (waitingRequired(command)) return;
+			if (waitingRequired(command,null)) return;
 			if (command.eid==eid) {
 				// Second Phase が終わって同期が終了。
 				checkAck(command);
@@ -112,13 +112,13 @@
 				return;
 			} else if (command.eid == eid){ 
 				// 編集コマンドが一周して来た
-				// if (waitingRequired(command)) return;
+				if (waitingRequired(command,null)) return;
 				checkReturnedCommand(command);
 				return;
 			}
 
 			//他のエディタからの編集コマンド
-			// if (waitingRequired(command)) return;
+			if (waitingRequired(command,null)) return;
 			translator.transReceiveCmd(next,command);
 
 			sendEditorCommand(command);
@@ -158,13 +158,13 @@
 //		assert(count==0);
 //	}
 
-	private boolean waitingRequired(REPCommand command) {
+	private boolean waitingRequired(REPCommand command, REPSocketChannel<REPCommand> channel) {
 		if (hasWaitingCommand()) {
 			// We cannot do this operation before watingCommandQueue.
 			addWaitingCommand(new PacketSet(channel, this, new REPCommand(command)));
 			return true;
 		} else if (isMerging()) { 
-			addWaitingCommand(new PacketSet(getChannel(), this, new REPCommand(command)));
+			addWaitingCommand(new PacketSet(channel, this, new REPCommand(command)));
 			return true;
 		} 
 		//ServerMainLoop.logger.writeLog("Editor eid:"+eid+" no waiting");
@@ -401,7 +401,7 @@
 	public void send(REPCommand command) {
 		if (command.eid == REP.MERGE_EID.id || 
 				command.cmd==REP.SMCMD_END_MERGE ||
-				!waitingRequired(command)) {
+				!waitingRequired(command,channel)) {
 			super.send(command);
 		}
 	}
@@ -466,8 +466,10 @@
 			}
 			PacketSet p = w.remove(0);
 			try {
-				send(p.command);
-				// manage(p.command);
+				if (p.channel!=null)
+					send(p.command);
+				else
+					manage(p.command);
 			} catch (Exception e1) {
 				assert false;
 				manager.close(p.channel);