Mercurial Hosting > luan
comparison src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @ 960:3cd4c706a61f
simplify ChannelEndPoint
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 13 Oct 2016 21:29:19 -0600 |
parents | 7b94f5b33c64 |
children | 790c01734386 |
comparison
equal
deleted
inserted
replaced
959:7b94f5b33c64 | 960:3cd4c706a61f |
---|---|
170 updateKey(); | 170 updateKey(); |
171 } | 171 } |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 /* ------------------------------------------------------------ */ | |
176 /** | |
177 * Called when a dispatched thread is no longer handling the endpoint. | |
178 * The selection key operations are updated. | |
179 * @return If false is returned, the endpoint has been redispatched and | |
180 * thread must keep handling the endpoint. | |
181 */ | |
182 private synchronized void undispatch() | |
183 { | |
184 _state = STATE_UNDISPATCHED; | |
185 updateKey(); | |
186 } | |
187 | |
188 @Override | 175 @Override |
189 public int fill(Buffer buffer) throws IOException | 176 public int fill(Buffer buffer) throws IOException |
190 { | 177 { |
191 int fill=super.fill(buffer); | 178 int fill=super.fill(buffer); |
192 return fill; | 179 return fill; |
430 } | 417 } |
431 } | 418 } |
432 | 419 |
433 private void handle() | 420 private void handle() |
434 { | 421 { |
435 boolean dispatched = true; | |
436 try | 422 try |
437 { | 423 { |
438 try | 424 try |
439 { | 425 { |
440 while(true) | 426 while(true) |
441 { | 427 { |
442 final AsyncConnection next = (AsyncConnection)_connection.handle(); | 428 final AsyncConnection next = (AsyncConnection)_connection.handle(); |
443 if (next!=_connection) | 429 if (next==_connection) |
444 { | 430 break; |
445 LOG.debug("{} replaced {}",next,_connection); | 431 LOG.debug("{} replaced {}",next,_connection); |
446 _connection=next; | 432 _connection=next; |
447 continue; | |
448 } | |
449 break; | |
450 } | 433 } |
451 } | 434 } |
452 catch (ClosedChannelException e) | 435 catch (ClosedChannelException e) |
453 { | 436 { |
454 LOG.trace("",e); | 437 LOG.trace("",e); |
484 { | 467 { |
485 LOG.warn("onInputShutdown failed", x); | 468 LOG.warn("onInputShutdown failed", x); |
486 try{close();} | 469 try{close();} |
487 catch(IOException e2){LOG.trace("",e2);} | 470 catch(IOException e2){LOG.trace("",e2);} |
488 } | 471 } |
489 finally | 472 } |
490 { | |
491 updateKey(); | |
492 } | |
493 } | |
494 undispatch(); | |
495 dispatched = false; | |
496 } | 473 } |
497 } | 474 } |
498 finally | 475 finally |
499 { | 476 { |
500 if (dispatched) | 477 _state = STATE_UNDISPATCHED; |
501 { | 478 updateKey(); |
502 undispatch(); | |
503 } | |
504 } | 479 } |
505 } | 480 } |
506 | 481 |
507 /* ------------------------------------------------------------ */ | 482 /* ------------------------------------------------------------ */ |
508 /* | 483 /* |