| | 840 | | addhosts(mp, rmp) |
| | 841 | | struct pmsg *mp; |
| | 842 | | struct pmsg *rmp; |
| | 843 | | { |
| | 844 | | struct hostd *hp, *hp2; |
| | 845 | | struct pmsg *mp2; |
| | 846 | | struct waitc *wp = 0; |
| | 847 | | struct waitc_add *wxp = 0; |
| | 848 | | int i, j; |
| | 849 | | int count; |
| | 850 | | int ngood; |
| | 851 | | int ntid; |
| | 852 | | struct hostent *he; |
| | 853 | | int maxhostid = (tidhmask >> ffs(tidhmask) - 1); |
| | 854 | | int hh; |
| | 855 | | int pid; |
| | 856 | | int *tids; |
| | 857 | | char *winpvmdpath; |
| | 858 | | char *pvmdpath; |
| | 859 | | char *vmid; |
| | 860 | | char *buf; |
| | 861 | | int len; |
| | 862 | | |
| | 863 | | |
| | 864 | | |
| | 865 | | |
| | 866 | | |
| | 867 | | |
| | 868 | | if (busyadding) { |
| | 869 | | |
| | 870 | | |
| | 871 | | |
| | 872 | | pkint(rmp, PvmAlready);
|
| | 873 | | sendmessage(rmp); |
| | 874 | | return 0; |
| | 875 | | } |
| | 876 | | |
| | 877 | | busyadding = 1; |
| | 878 | | |
| | 879 | | |
| | 880 | | |
| | 881 | | if (upkint(mp, &count) || count < 1 || count > maxhostid) { |
| | 882 | | pvmlogerror("addhosts() bad msg format\n"); |
| | 883 | | goto bad; |
| | 884 | | } |
| | 885 | | |
| | 886 | | |
| | 887 | | |
| | 888 | | |
| | 889 | | |
| | 890 | | wp = wait_new(WT_HOSTSTART);
|
| | 891 | | wp->wa_tid = mp->m_src; |
| | 892 | | wp->wa_dep = mp->m_wid; |
| | 893 | | wxp = TALLOC(1, struct waitc_add, "waix");
|
| | 894 | | wxp->w_num = count; |
| | 895 | | wxp->w_hosts = TALLOC(count, struct hostd *, "waiv");
|
| | 896 | | BZERO((char*)wxp->w_hosts, count * sizeof(struct hostd *));
|
| | 897 | | wp->wa_spec = (void *)wxp; |
| | 898 | | |
| | 899 | | for (i = 0; i < count; i++) { |
| | 900 | | hp = hd_new(0); |
| | 901 | | wxp->w_hosts[i] = hp; |
| | 902 | | if (upkstralloc(mp, &buf)) { |
| | 903 | | pvmlogerror("addhosts() bad msg format\n"); |
| | 904 | | goto bad; |
| | 905 | | } |
| | 906 | | if (parsehost(buf, hp)) { |
| | 907 | | hp->hd_err = PvmBadParam;
|
| | 908 | | |
| | 909 | | } else { |
| | 910 | | |
| | 911 | | |
| | 912 | | |
| | 913 | | if (filehosts && |
| | 914 | | ((hp2 = nametohost(filehosts, hp->hd_name)) |
| | 915 | | || (hp2 = filehosts->ht_hosts[0]))) |
| | 916 | | applydefaults(hp, hp2); |
| | 917 | | } |
| | 918 | | PVM_FREE(buf);
|
| | 919 | | } |
| | 920 | | |
| | 921 | | |
| | 922 | | |
| | 923 | | |
| | 924 | | |
| | 925 | | |
| | 926 | | hp = hosts->ht_hosts[hosts->ht_local]; |
| | 927 | | |
| | 928 | | if ( hp->hd_sad.sin_addr.s_addr == htonl(0x7f000001) ) {
|
| | 929 | | |
| | 930 | | |
| | 931 | | |
| | 932 | | |
| | 933 | | for (i = 0; i < count; i++) { |
| | 934 | | hp = wxp->w_hosts[i]; |
| | 935 | | if (hp->hd_err) |
| | 936 | | continue; |
| | 937 | | hp->hd_err = PvmIPLoopback;
|
| | 938 | | } |
| | 939 | | } |
| | 940 | | |
| | 941 | | |
| | 942 | | |
| | 943 | | |
| | 944 | | |
| | 945 | | ngood = 0; |
| | 946 | | for (i = 0; i < count; i++) { |
| | 947 | | hp = wxp->w_hosts[i]; |
| | 948 | | if (hp->hd_err) |
| | 949 | | continue; |
| | 950 | | |
| | 951 | | if (he = gethostbyname(hp->hd_aname ? hp->hd_aname : hp->hd_name)) { |
| | 952 | | BCOPY(he->h_addr_list[0], (char*)&hp->hd_sad.sin_addr,
|
| | 953 | | sizeof(struct in_addr)); |
| | 954 | | |
| | 955 | | } else { |
| | 956 | | if (pvmdebmask & PDMSTARTUP) {
|
| | 957 | | pvmlogprintf( |
| | 958 | | "start_slaves() can't gethostbyname: %s\n", |
| | 959 | | hp->hd_name); |
| | 960 | | } |
| | 961 | | hp->hd_err = PvmNoHost;
|
| | 962 | | continue; |
| | 963 | | } |
| | 964 | | |
| | 965 | | |
| | 966 | | |
| | 967 | | if (!(hp->hd_flag & HF_OVERLOAD)) {
|
| | 968 | | for (hh = hosts->ht_last; hh > 0; hh--) |
| | 969 | | if ((hp2 = hosts->ht_hosts[hh]) |
| | 970 | | && (hp2->hd_sad.sin_addr.s_addr == hp->hd_sad.sin_addr.s_addr)) { |
| | 971 | | hp->hd_err = PvmDupHost;
|
| | 972 | | break; |
| | 973 | | } |
| | 974 | | if (hp->hd_err) |
| | 975 | | continue; |
| | 976 | | |
| | 977 | | |
| | 978 | | |
| | 979 | | for (j = i; j-- > 0; ) |
| | 980 | | if (hp->hd_sad.sin_addr.s_addr |
| | 981 | | == wxp->w_hosts[j]->hd_sad.sin_addr.s_addr) { |
| | 982 | | hp->hd_err = PvmDupHost;
|
| | 983 | | break; |
| | 984 | | } |
| | 985 | | if (hp->hd_err) |
| | 986 | | continue; |
| | 987 | | } |
| | 988 | | |
| | 989 | | ngood++; |
| | 990 | | } |
| | 991 | | |
| | 992 | | |
| | 993 | | |
| | 994 | | |
| | 995 | | |
| | 996 | | ntid = ngood; |
| | 997 | | tids = TALLOC(ngood, int, "xxx");
|
| | 998 | | hostids_new(&ntid, tids); |
| | 999 | | if (ntid < ngood) { |
| | 1000 | | pvmlogerror("addhosts() out of hostids\n"); |
| | 1001 | | ngood = ntid; |
| | 1002 | | } |
| | 1003 | | for (j = i = 0; i < count; i++) { |
| | 1004 | | hp = wxp->w_hosts[i]; |
| | 1005 | | if (hp->hd_err) |
| | 1006 | | continue; |
| | 1007 | | if (j < ntid) |
| | 1008 | | hp->hd_hostpart = tids[j++]; |
| | 1009 | | else |
| | 1010 | | hp->hd_err = PvmOutOfRes;
|
| | 1011 | | } |
| | 1012 | | PVM_FREE(tids);
|
| | 1013 | | |
| | 1014 | | |
| | 1015 | | |
| | 1016 | | |
| | 1017 | | |
| | 1018 | | |
| | 1019 | | |
| | 1020 | | |
| | 1021 | | |
| | 1022 | | wp->wa_mesg = rmp; |
| | 1023 | | |
| | 1024 | | |
| | 1025 | | |