Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/handler/Editor.java @ 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 |
comparison
equal
deleted
inserted
replaced
443:bd086be276d2 | 444:97593c486db6 |
---|---|
80 | 80 |
81 public void translate(REPCommand command){ | 81 public void translate(REPCommand command){ |
82 switch(command.cmd) { | 82 switch(command.cmd) { |
83 case REPCMD_INSERT_ACK: | 83 case REPCMD_INSERT_ACK: |
84 case REPCMD_DELETE_ACK: | 84 case REPCMD_DELETE_ACK: |
85 // if (waitingRequired(command)) return; | 85 if (waitingRequired(command,null)) return; |
86 if (command.eid==eid) { | 86 if (command.eid==eid) { |
87 // Second Phase が終わって同期が終了。 | 87 // Second Phase が終わって同期が終了。 |
88 checkAck(command); | 88 checkAck(command); |
89 // SessionManager.logger.writeLog("Complete "+command); | 89 // SessionManager.logger.writeLog("Complete "+command); |
90 checkQuit(); | 90 checkQuit(); |
110 } | 110 } |
111 checkEndMerge(); | 111 checkEndMerge(); |
112 return; | 112 return; |
113 } else if (command.eid == eid){ | 113 } else if (command.eid == eid){ |
114 // 編集コマンドが一周して来た | 114 // 編集コマンドが一周して来た |
115 // if (waitingRequired(command)) return; | 115 if (waitingRequired(command,null)) return; |
116 checkReturnedCommand(command); | 116 checkReturnedCommand(command); |
117 return; | 117 return; |
118 } | 118 } |
119 | 119 |
120 //他のエディタからの編集コマンド | 120 //他のエディタからの編集コマンド |
121 // if (waitingRequired(command)) return; | 121 if (waitingRequired(command,null)) return; |
122 translator.transReceiveCmd(next,command); | 122 translator.transReceiveCmd(next,command); |
123 | 123 |
124 sendEditorCommand(command); | 124 sendEditorCommand(command); |
125 return; | 125 return; |
126 default: | 126 default: |
156 // } | 156 // } |
157 // } | 157 // } |
158 // assert(count==0); | 158 // assert(count==0); |
159 // } | 159 // } |
160 | 160 |
161 private boolean waitingRequired(REPCommand command) { | 161 private boolean waitingRequired(REPCommand command, REPSocketChannel<REPCommand> channel) { |
162 if (hasWaitingCommand()) { | 162 if (hasWaitingCommand()) { |
163 // We cannot do this operation before watingCommandQueue. | 163 // We cannot do this operation before watingCommandQueue. |
164 addWaitingCommand(new PacketSet(channel, this, new REPCommand(command))); | 164 addWaitingCommand(new PacketSet(channel, this, new REPCommand(command))); |
165 return true; | 165 return true; |
166 } else if (isMerging()) { | 166 } else if (isMerging()) { |
167 addWaitingCommand(new PacketSet(getChannel(), this, new REPCommand(command))); | 167 addWaitingCommand(new PacketSet(channel, this, new REPCommand(command))); |
168 return true; | 168 return true; |
169 } | 169 } |
170 //ServerMainLoop.logger.writeLog("Editor eid:"+eid+" no waiting"); | 170 //ServerMainLoop.logger.writeLog("Editor eid:"+eid+" no waiting"); |
171 return false; | 171 return false; |
172 } | 172 } |
399 */ | 399 */ |
400 @Override | 400 @Override |
401 public void send(REPCommand command) { | 401 public void send(REPCommand command) { |
402 if (command.eid == REP.MERGE_EID.id || | 402 if (command.eid == REP.MERGE_EID.id || |
403 command.cmd==REP.SMCMD_END_MERGE || | 403 command.cmd==REP.SMCMD_END_MERGE || |
404 !waitingRequired(command)) { | 404 !waitingRequired(command,channel)) { |
405 super.send(command); | 405 super.send(command); |
406 } | 406 } |
407 } | 407 } |
408 | 408 |
409 @Override | 409 @Override |
464 waitingCommandInMerge = w; | 464 waitingCommandInMerge = w; |
465 return; | 465 return; |
466 } | 466 } |
467 PacketSet p = w.remove(0); | 467 PacketSet p = w.remove(0); |
468 try { | 468 try { |
469 send(p.command); | 469 if (p.channel!=null) |
470 // manage(p.command); | 470 send(p.command); |
471 else | |
472 manage(p.command); | |
471 } catch (Exception e1) { | 473 } catch (Exception e1) { |
472 assert false; | 474 assert false; |
473 manager.close(p.channel); | 475 manager.close(p.channel); |
474 return; | 476 return; |
475 } | 477 } |