| | 670 | | tm_conn2(tp, mp) |
| | 671 | | struct task *tp; |
| | 672 | | struct pmsg *mp; |
| | 673 | | { |
| | 674 | | int tid; |
| | 675 | | int pid; |
| | 676 | | int cookie; |
| | 677 | | struct task *tp2; |
| | 678 | | struct pmsg *mp2; |
| | 679 | | int cc; |
| | 680 | | char c; |
| | 681 | | char *taskname = (char *) NULL;
|
| | 682 | | |
| | 683 | | if (upkint(mp, &pid) || upkint(mp, &cookie)) { |
| | 684 | | pvmlogerror("tm_conn2() bad msg format\n"); |
| | 685 | | goto bail; |
| | 686 | | } |
| | 687 | | if (!cookie) |
| | 688 | | cookie = pid; |
| | 689 | | |
| | 690 | | if (!(tp->t_flag & TF_AUTH)) {
|
| | 691 | | pvmlogprintf("tm_conn2() message from t%x, TF_AUTH not set\n", |
| | 692 | | tp->t_tid); |
| | 693 | | return 0; |
| | 694 | | } |
| | 695 | | |
| | 696 | | |
| | 697 | | |
| | 698 | | |
| | 699 | | |
| | 700 | | #ifndef NOPROT |
| | 701 | | |
| | 702 | | if ((cc = read(tp->t_authfd, &c, 1)) == -1) { |
| | 703 | | pvmlogperror("tm_conn2() can't read d-auth file"); |
| | 704 | | return 0; |
| | 705 | | } |
| | 706 | | |
| | 707 | | if (cc != 1) { |
| | 708 | | pvmlogerror("tm_conn2() task didn't validate itself\n"); |
| | 709 | | goto bail; |
| | 710 | | } |
| | 711 | | |
| | 712 | | (void)close(tp->t_authfd); |
| | 713 | | tp->t_authfd = -1; |
| | 714 | | (void)unlink(tp->t_authnam); |
| | 715 | | |
| | 716 | | #endif |
| | 717 | | |
| | 718 | | PVM_FREE(tp->t_authnam);
|
| | 719 | | tp->t_authnam = 0; |
| | 720 | | |
| | 721 | | |
| | 722 | | |
| | 723 | | |
| | 724 | | |
| | 725 | | |
| | 726 | | if ((tp2 = task_findpid(cookie)) && !(tp2->t_flag & (TF_AUTH|TF_CONN))) {
|
| | 727 | | if (pvmdebmask & PDMTASK) {
|
| | 728 | | pvmlogprintf("tm_conn2() reconnect task t%x\n", tp2->t_tid); |
| | 729 | | } |
| | 730 | | tp->t_sched = tp2->t_sched; |
| | 731 | | |
| | 732 | | #ifdef IMA_BEOLIN |
| | 733 | | } else if ( (tp2 = mpp_conn(tp)) |
| | 734 | | && !(tp2->t_flag & (TF_AUTH|TF_CONN)) ) { |
| | 735 | | if (pvmdebmask & PDMTASK) { |
| | 736 | | pvmlogprintf( |
| | 737 | | "tm_conn2() reconnect task t%x pid=%d name=%s\n", |
| | 738 | | tp2->t_tid,tp2->t_pid, tp2->t_a_out ); |
| | 739 | | } |
| | 740 | | #endif |
| | 741 | | |
| | 742 | | } else { |
| | 743 | | if ((tid = tid_new()) < 0) { |
| | 744 | | pvmlogerror("tm_conn2() out of tids?\n"); |
| | 745 | | goto bail; |
| | 746 | | } |
| | 747 | | if ((tp2 = task_new(tid)) == NULL) {
|
| | 748 | | pvmlogerror("tm_conn2() too many tasks?\n"); |
| | 749 | | goto bail; |
| | 750 | | } |
| | 751 | | |
| | 752 | | if ( !upkstralloc(mp, &taskname) ) { |
| | 753 | | tp2->t_a_out = taskname; |
| | 754 | | } |
| | 755 | | |
| | 756 | | if (pvmschedtid) { |
| | 757 | | |
| | 758 | | |
| | 759 | | tp->t_sched = pvmschedtid; |