console.c (7636cb21f250f0485ca6052ffadc80ace93e6358) | console.c (4d39be2b45b5ac811d28452e6eb629ac64aebfc4) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 573 unchanged lines hidden (view full) --- 582 (el_func_t)close_one_vcc_fd); 583 } 584 585 586 (void) vntsd_que_rm(&groupp->no_cons_clientpq, clientp); 587 588 if ((groupp->no_cons_clientpq == NULL) && 589 (groupp->status & VNTSD_GROUP_SIG_WAIT)) { | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 573 unchanged lines hidden (view full) --- 582 (el_func_t)close_one_vcc_fd); 583 } 584 585 586 (void) vntsd_que_rm(&groupp->no_cons_clientpq, clientp); 587 588 if ((groupp->no_cons_clientpq == NULL) && 589 (groupp->status & VNTSD_GROUP_SIG_WAIT)) { |
590 /* group is waiting to be deleted */ 591 groupp->status &= ~VNTSD_GROUP_SIG_WAIT; | 590 /* 591 * group is waiting to be deleted. - signal the group's 592 * listen thread - the VNTSD_GROUP_SIG_WAIT state will 593 * be cleared when the listen thread exits. 594 */ |
592 (void) cond_signal(&groupp->cvp); 593 } 594 (void) mutex_unlock(&groupp->lock); 595 596 (void) mutex_destroy(&clientp->lock); 597 free(clientp); 598 599 thr_exit(0); --- 7 unchanged lines hidden (view full) --- 607 608 D1(stderr, "t@%d console_chk_status() status=%d " 609 "client status=%x num consoles=%d \n", 610 thr_self(), status, clientp->status, groupp->num_cons); 611 612 (void) snprintf(err_msg, VNTSD_LINE_LEN, "console_chk_status client%d" 613 " num_cos=%d", clientp->sockfd, groupp->num_cons); 614 | 595 (void) cond_signal(&groupp->cvp); 596 } 597 (void) mutex_unlock(&groupp->lock); 598 599 (void) mutex_destroy(&clientp->lock); 600 free(clientp); 601 602 thr_exit(0); --- 7 unchanged lines hidden (view full) --- 610 611 D1(stderr, "t@%d console_chk_status() status=%d " 612 "client status=%x num consoles=%d \n", 613 thr_self(), status, clientp->status, groupp->num_cons); 614 615 (void) snprintf(err_msg, VNTSD_LINE_LEN, "console_chk_status client%d" 616 " num_cos=%d", clientp->sockfd, groupp->num_cons); 617 |
618 /* 619 * obtain group lock to protect groupp->num_cons. 620 * When groupp->num_cons == 0, close client and exit the tread. 621 */ 622 (void) mutex_lock(&groupp->lock); 623 |
|
615 if (groupp->num_cons == 0) { 616 /* no more console in the group */ | 624 if (groupp->num_cons == 0) { 625 /* no more console in the group */ |
626 (void) mutex_unlock(&groupp->lock); |
|
617 client_fini(groupp, clientp); | 627 client_fini(groupp, clientp); |
628 return; |
|
618 } 619 620 if (status == VNTSD_STATUS_INTR) { 621 /* reason for signal? */ 622 status = vntsd_cons_chk_intr(clientp); 623 } 624 625 switch (status) { 626 627 case VNTSD_STATUS_CLIENT_QUIT: | 629 } 630 631 if (status == VNTSD_STATUS_INTR) { 632 /* reason for signal? */ 633 status = vntsd_cons_chk_intr(clientp); 634 } 635 636 switch (status) { 637 638 case VNTSD_STATUS_CLIENT_QUIT: |
639 (void) mutex_unlock(&groupp->lock); |
|
628 client_fini(groupp, clientp); 629 return; 630 631 case VNTSD_STATUS_RESELECT_CONS: | 640 client_fini(groupp, clientp); 641 return; 642 643 case VNTSD_STATUS_RESELECT_CONS: |
632 assert(clientp->cons); | 644 645 if (clientp->cons == NULL) { 646 /* 647 * domain was deleted before client connects to it 648 * connect to other console in the same group 649 */ 650 (void) mutex_unlock(&groupp->lock); 651 client_init(clientp); 652 return; 653 } 654 |
633 if ((groupp->num_cons == 1) && | 655 if ((groupp->num_cons == 1) && |
634 (groupp->conspq->handle == clientp->cons)) { | 656 ((clientp->status & VNTSD_CLIENT_CONS_DELETED) || 657 (groupp->conspq->handle == clientp->cons))) { |
635 /* no other selection available */ | 658 /* no other selection available */ |
659 (void) mutex_unlock(&groupp->lock); |
|
636 client_fini(groupp, clientp); 637 } else { | 660 client_fini(groupp, clientp); 661 } else { |
662 (void) mutex_unlock(&groupp->lock); |
|
638 client_init(clientp); 639 } | 663 client_init(clientp); 664 } |
665 |
|
640 return; 641 642 case VNTSD_STATUS_VCC_IO_ERR: 643 if ((clientp->status & VNTSD_CLIENT_CONS_DELETED) == 0) { 644 /* check if console was deleted */ | 666 return; 667 668 case VNTSD_STATUS_VCC_IO_ERR: 669 if ((clientp->status & VNTSD_CLIENT_CONS_DELETED) == 0) { 670 /* check if console was deleted */ |
671 (void) mutex_unlock(&groupp->lock); |
|
645 status = vntsd_vcc_err(clientp->cons); | 672 status = vntsd_vcc_err(clientp->cons); |
673 (void) mutex_lock(&groupp->lock); |
|
646 } 647 648 if (status != VNTSD_STATUS_CONTINUE) { 649 /* console was deleted */ | 674 } 675 676 if (status != VNTSD_STATUS_CONTINUE) { 677 /* console was deleted */ |
650 if (groupp->num_cons == 1) { | 678 if (groupp->num_cons <= 1) { 679 (void) mutex_unlock(&groupp->lock); |
651 client_fini(groupp, clientp); | 680 client_fini(groupp, clientp); |
681 return; |
|
652 } 653 } 654 | 682 } 683 } 684 |
685 (void) mutex_unlock(&groupp->lock); |
|
655 /* console is ok */ 656 client_init(clientp); 657 return; 658 659 case VNTSD_STATUS_MOV_CONS_FORWARD: 660 case VNTSD_STATUS_MOV_CONS_BACKWARD: 661 if (groupp->num_cons == 1) { 662 /* same console */ | 686 /* console is ok */ 687 client_init(clientp); 688 return; 689 690 case VNTSD_STATUS_MOV_CONS_FORWARD: 691 case VNTSD_STATUS_MOV_CONS_BACKWARD: 692 if (groupp->num_cons == 1) { 693 /* same console */ |
694 (void) mutex_unlock(&groupp->lock); |
|
663 return; 664 } 665 666 /* get selected console */ | 695 return; 696 } 697 698 /* get selected console */ |
667 (void) mutex_lock(&(clientp->cons->group->lock)); 668 clientp->cons = vntsd_que_pos(clientp->cons->group->conspq, | 699 clientp->cons = vntsd_que_pos(groupp->conspq, |
669 clientp->cons, 670 (status == VNTSD_STATUS_MOV_CONS_FORWARD)?(1):(-1)); | 700 clientp->cons, 701 (status == VNTSD_STATUS_MOV_CONS_FORWARD)?(1):(-1)); |
671 (void) mutex_unlock(&(clientp->cons->group->lock)); | 702 (void) mutex_unlock(&groupp->lock); |
672 return; 673 674 case VNTSD_SUCCESS: 675 case VNTSD_STATUS_CONTINUE: 676 case VNTSD_STATUS_NO_CONS: | 703 return; 704 705 case VNTSD_SUCCESS: 706 case VNTSD_STATUS_CONTINUE: 707 case VNTSD_STATUS_NO_CONS: |
708 (void) mutex_unlock(&groupp->lock); |
|
677 client_init(clientp); 678 return; 679 680 case VNTSD_ERR_INVALID_INPUT: | 709 client_init(clientp); 710 return; 711 712 case VNTSD_ERR_INVALID_INPUT: |
713 (void) mutex_unlock(&groupp->lock); |
|
681 return; 682 683 default: 684 /* fatal error */ | 714 return; 715 716 default: 717 /* fatal error */ |
718 (void) mutex_unlock(&groupp->lock); |
|
685 vntsd_log(status, err_msg); 686 client_fini(groupp, clientp); 687 return; 688 } 689} 690 691/* console thread */ 692void * --- 45 unchanged lines hidden (view full) --- 738 739 num_cons = vntsd_chk_group_total_cons(groupp); 740 741 if ((num_cons > 1) && (clientp->cons == NULL)) { 742 /* console to connect to */ 743 rv = read_cmd(clientp, prompt, &cmd); 744 /* check error and may exit */ 745 console_chk_status(groupp, clientp, rv); | 719 vntsd_log(status, err_msg); 720 client_fini(groupp, clientp); 721 return; 722 } 723} 724 725/* console thread */ 726void * --- 45 unchanged lines hidden (view full) --- 772 773 num_cons = vntsd_chk_group_total_cons(groupp); 774 775 if ((num_cons > 1) && (clientp->cons == NULL)) { 776 /* console to connect to */ 777 rv = read_cmd(clientp, prompt, &cmd); 778 /* check error and may exit */ 779 console_chk_status(groupp, clientp, rv); |
780 781 /* any console is removed from group? */ 782 num_cons = vntsd_chk_group_total_cons(groupp); 783 if (num_cons <= 1) { 784 cmd = ' '; 785 } |
|
746 } 747 748 switch (cmd) { 749 750 case 'l': 751 752 /* list domain names */ 753 rv = list_all_domains(groupp, clientp); 754 break; 755 756 757 case 'q': 758 759 rv = VNTSD_STATUS_CLIENT_QUIT; 760 break; 761 762 case ' ': 763 | 786 } 787 788 switch (cmd) { 789 790 case 'l': 791 792 /* list domain names */ 793 rv = list_all_domains(groupp, clientp); 794 break; 795 796 797 case 'q': 798 799 rv = VNTSD_STATUS_CLIENT_QUIT; 800 break; 801 802 case ' ': 803 |
804 if (num_cons == 0) 805 /* no console in the group */ 806 break; 807 |
|
764 if (clientp->cons == NULL) { 765 if (num_cons == 1) { 766 /* by pass selecting console */ 767 consp = (vntsd_cons_t *) 768 (groupp->conspq->handle); 769 } else { 770 continue; 771 } --- 45 unchanged lines hidden --- | 808 if (clientp->cons == NULL) { 809 if (num_cons == 1) { 810 /* by pass selecting console */ 811 consp = (vntsd_cons_t *) 812 (groupp->conspq->handle); 813 } else { 814 continue; 815 } --- 45 unchanged lines hidden --- |