comparison src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @ 949:e9088af3787f

remove SelectSet._changes
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 11 Oct 2016 23:18:13 -0600
parents f5aefdc4a81a
children a778413aefc0
comparison
equal deleted inserted replaced
948:f5aefdc4a81a 949:e9088af3787f
499 changed=_interestOps!=current_ops; 499 changed=_interestOps!=current_ops;
500 } 500 }
501 501
502 if(changed) 502 if(changed)
503 { 503 {
504 _selectSet.addChange(this); 504 doUpdateKey();
505 _selectSet.wakeup(); 505 _selectSet.wakeup();
506 } 506 }
507 } 507 }
508 508
509 509
510 /* ------------------------------------------------------------ */ 510 /* ------------------------------------------------------------ */
511 /** 511 /**
512 * Synchronize the interestOps with the actual key. Call is scheduled by a call to updateKey 512 * Synchronize the interestOps with the actual key. Call is scheduled by a call to updateKey
513 */ 513 */
514 void doUpdateKey() 514 synchronized void doUpdateKey()
515 { 515 {
516 synchronized (this) 516 if (getChannel().isOpen())
517 { 517 {
518 if (getChannel().isOpen()) 518 if (_interestOps>0)
519 { 519 {
520 if (_interestOps>0) 520 if (_key==null || !_key.isValid())
521 { 521 {
522 if (_key==null || !_key.isValid()) 522 SelectableChannel sc = (SelectableChannel)getChannel();
523 { 523 if (sc.isRegistered())
524 SelectableChannel sc = (SelectableChannel)getChannel(); 524 {
525 if (sc.isRegistered()) 525 updateKey();
526 }
527 else
528 {
529 try
526 { 530 {
527 updateKey(); 531 _key=((SelectableChannel)getChannel()).register(_selectSet.getSelector(),_interestOps,this);
528 } 532 }
529 else 533 catch (Exception e)
530 { 534 {
531 try 535 LOG.trace("",e);
536 if (_key!=null && _key.isValid())
532 { 537 {
533 _key=((SelectableChannel)getChannel()).register(_selectSet.getSelector(),_interestOps,this); 538 _key.cancel();
534 } 539 }
535 catch (Exception e) 540
541 if (_open)
536 { 542 {
537 LOG.trace("",e); 543 _selectSet.destroyEndPoint(this);
538 if (_key!=null && _key.isValid())
539 {
540 _key.cancel();
541 }
542
543 if (_open)
544 {
545 _selectSet.destroyEndPoint(this);
546 }
547 _open=false;
548 _key = null;
549 } 544 }
545 _open=false;
546 _key = null;
550 } 547 }
551 } 548 }
552 else
553 {
554 _key.interestOps(_interestOps);
555 }
556 } 549 }
557 else 550 else
558 { 551 {
559 if (_key!=null && _key.isValid()) 552 _key.interestOps(_interestOps);
560 _key.interestOps(0);
561 else
562 _key=null;
563 } 553 }
564 } 554 }
565 else 555 else
566 { 556 {
567 if (_key!=null && _key.isValid()) 557 if (_key!=null && _key.isValid())
568 _key.cancel(); 558 _key.interestOps(0);
569 559 else
570 if (_open) 560 _key=null;
571 { 561 }
572 _open=false; 562 }
573 _selectSet.destroyEndPoint(this); 563 else
574 } 564 {
575 _key = null; 565 if (_key!=null && _key.isValid())
576 } 566 _key.cancel();
567
568 if (_open)
569 {
570 _open=false;
571 _selectSet.destroyEndPoint(this);
572 }
573 _key = null;
577 } 574 }
578 } 575 }
579 576
580 /* ------------------------------------------------------------ */ 577 /* ------------------------------------------------------------ */
581 /* 578 /*