| | 1083 | | tm_spawn(tp, mp) |
| | 1084 | | struct task *tp; |
| | 1085 | | struct pmsg *mp; |
| | 1086 | | { |
| | 1087 | | char *where = 0; |
| | 1088 | | struct waitc *wp; |
| | 1089 | | struct waitc_spawn *wxp = 0; |
| | 1090 | | struct htab *htp; |
| | 1091 | | struct hostd *hp; |
| | 1092 | | int hh; |
| | 1093 | | int i; |
| | 1094 | | char *wd = 0; |
| | 1095 | | char *wdenv = 0; |
| | 1096 | | char *ptr; |
| | 1097 | | int sz; |
| | 1098 | | |
| | 1099 | | |
| | 1100 | | |
| | 1101 | | |
| | 1102 | | |
| | 1103 | | wxp = TALLOC(1, struct waitc_spawn, "waix");
|
| | 1104 | | BZERO((char*)wxp, sizeof(struct waitc_spawn));
|
| | 1105 | | |
| | 1106 | | if (upkstralloc(mp, &wxp->w_file) |
| | 1107 | | || upkint(mp, &wxp->w_flags) |
| | 1108 | | || upkstralloc(mp, &where) |
| | 1109 | | || upkint(mp, &wxp->w_veclen) |
| | 1110 | | || upkint(mp, &wxp->w_argc)) |
| | 1111 | | goto bad; |
| | 1112 | | |
| | 1113 | | if (wxp->w_veclen < 1) |
| | 1114 | | goto bad; |
| | 1115 | | |
| | 1116 | | wxp->w_argv = TALLOC(wxp->w_argc + 1, char*, "argv");
|
| | 1117 | | BZERO((char*)wxp->w_argv, (wxp->w_argc + 1) * sizeof(char*));
|
| | 1118 | | for (i = 0; i < wxp->w_argc; i++) |
| | 1119 | | if (upkstralloc(mp, &wxp->w_argv[i])) |
| | 1120 | | goto bad; |
| | 1121 | | |
| | 1122 | | if (upkuint(mp, &wxp->w_outtid) |
| | 1123 | | || upkuint(mp, &wxp->w_outctx) |
| | 1124 | | || upkuint(mp, &wxp->w_outtag) |
| | 1125 | | || upkuint(mp, &wxp->w_trctid) |
| | 1126 | | || upkuint(mp, &wxp->w_trcctx) |
| | 1127 | | || upkuint(mp, &wxp->w_trctag)) |
| | 1128 | | goto bad; |
| | 1129 | | |
| | 1130 | | |
| | 1131 | | |
| | 1132 | | |
| | 1133 | | |
| | 1134 | | ptr = where; |
| | 1135 | | while ( *ptr != ':' && *ptr != '\0' ) |
| | 1136 | | ptr++; |
| | 1137 | | if ( *ptr == ':' ) { |
| | 1138 | | *ptr++ = '\0'; |
| | 1139 | | wd = ptr; |
| | 1140 | | } |
| | 1141 | | |
| | 1142 | | |
| | 1143 | | |
| | 1144 | | |
| | 1145 | | |
| | 1146 | | if (upkuint(mp, &wxp->w_nenv)) |
| | 1147 | | goto bad; |
| | 1148 | | sz = wxp->w_nenv + 1 + (wd ? 1 : 0); |
| | 1149 | | wxp->w_env = TALLOC(sz, char*, "env");
|
| | 1150 | | BZERO((char*)wxp->w_env, sz * sizeof(char*));
|
| | 1151 | | for (i = 0; i < wxp->w_nenv; i++) |
| | 1152 | | if (upkstralloc(mp, &wxp->w_env[i])) |
| | 1153 | | goto bad; |
| | 1154 | | |
| | 1155 | | |
| | 1156 | | |
| | 1157 | | |
| | 1158 | | |
| | 1159 | | if ( wd ) { |
| | 1160 | | sz = strlen(wd) + strlen("PVMSPAWNWD=") + 1; |
| | 1161 | | wdenv = TALLOC(sz, char, "wdenv");
|
| | 1162 | | sprintf( wdenv, "PVMSPAWNWD=%s", wd ); |
| | 1163 | | wxp->w_env[ (wxp->w_nenv)++ ] = STRALLOC( wdenv );
|
| | 1164 | | } |
| | 1165 | | |
| | 1166 | | |
| | 1167 | | |
| | 1168 | | |
| | 1169 | | |
| | 1170 | | if ((wxp->w_flags & (PvmTaskHost|PvmTaskArch)) && !where)
|
| | 1171 | | goto bad; |
| | 1172 | | |
| | 1173 | | htp = ht_new(1); |
| | 1174 | | |
| | 1175 | | if (wxp->w_flags & PvmTaskHost) {
|
| | 1176 | | if (hp = nametohost(hosts, where)) |
| | 1177 | | ht_insert(htp, hp); |
| | 1178 | | |
| | 1179 | | } else { |
| | 1180 | | if (wxp->w_flags & PvmTaskArch) {
|
| | 1181 | | for (hh = hosts->ht_last; hh > 0; hh--) |
| | 1182 | | if ((hp = hosts->ht_hosts[hh]) |
| | 1183 | | && !strcmp(where, hp->hd_arch)) |
| | 1184 | | ht_insert(htp, hp); |
| | 1185 | | |
| | 1186 | | #ifdef IMA_BEOLIN |
| | | | ... |
| | 1188 | | } else if (wxp->w_flags & PvmMppFront) { |
| | 1189 | | hp = hosts->ht_hosts[hosts->ht_local]; |
| | 1190 | | ht_insert(htp, hp); |
| | 1191 | | #endif |
| | 1192 | | |
| | 1193 | | } else { |
| | 1194 | | ht_merge(htp, hosts); |
| | 1195 | | } |
| | 1196 | | } |
| | 1197 | | |
| | 1198 | | if (wxp->w_flags & PvmHostCompl) {
|
| | 1199 | | for (hh = hosts->ht_last; hh > 0; hh--) { |
| | 1200 | | if (hh <= htp->ht_last && (hp = htp->ht_hosts[hh])) |
| | 1201 | | ht_delete(htp, hp); |
| | 1202 | | else |
| | 1203 | | if (hp = hosts->ht_hosts[hh]) |
| | 1204 | | ht_insert(htp, hp); |
| | 1205 | | } |
| | 1206 | | } |
| | 1207 | | |
| | 1208 | | if (pvmdebmask & PDMTASK) {
|
| | 1209 | | pvmlogerror("tm_spawn() host set:\n"); |
| | 1210 | | ht_dump(htp); |
| | 1211 | | } |
| | 1212 | | |
| | 1213 | | if ( !(wxp->w_flags & PvmNoSpawnParent) ) {
|
| | 1214 | | wxp->w_ptid = tp->t_tid; |
| | 1215 | | } |
| | 1216 | | else |
| | 1217 | | wxp->w_ptid = PvmParentNotSet;
|
| | 1218 | | |
| | 1219 | | |
| | 1220 | | |
| | 1221 | | |
| | 1222 | | |
| | 1223 | | wxp->w_ht = htp; |
| | 1224 | | wxp->w_vec = TALLOC(wxp->w_veclen, int, "vec");
|
| | 1225 | | BZERO((char*)wxp->w_vec, wxp->w_veclen * sizeof(int));
|
| | 1226 | | wxp->w_togo = wxp->w_veclen; |
| | 1227 | | |