Print this page
make: unifdef for MAKETOOL and DISTRIBUTED (undefined)

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/bin/parallel.cc
          +++ new/usr/src/cmd/make/bin/parallel.cc
↓ open down ↓ 26 lines elided ↑ open up ↑
  27   27  
  28   28  /*
  29   29   *      parallel.cc
  30   30   *
  31   31   *      Deal with the parallel processing
  32   32   */
  33   33  
  34   34  /*
  35   35   * Included files
  36   36   */
  37      -#ifdef DISTRIBUTED
  38      -#include <avo/strings.h>        /* AVO_STRDUP() */
  39      -#include <dm/Avo_DoJobMsg.h>
  40      -#include <dm/Avo_MToolJobResultMsg.h>
  41      -#endif
  42   37  #include <errno.h>              /* errno */
  43   38  #include <fcntl.h>
  44   39  #include <mk/defs.h>
  45   40  #include <mksh/dosys.h>         /* redirect_io() */
  46   41  #include <mksh/macro.h>         /* expand_value() */
  47   42  #include <mksh/misc.h>          /* getmem() */
  48   43  #include <sys/signal.h>
  49   44  #include <sys/stat.h>
  50   45  #include <sys/types.h>
  51   46  #include <sys/utsname.h>
↓ open down ↓ 30 lines elided ↑ open up ↑
  82   77  static  int             pmake_max_jobs = 0;
  83   78  static  pid_t           process_running = -1;
  84   79  static  Running         *running_tail = &running_list;
  85   80  static  Name            subtree_conflict;
  86   81  static  Name            subtree_conflict2;
  87   82  
  88   83  
  89   84  /*
  90   85   * File table of contents
  91   86   */
  92      -#ifdef DISTRIBUTED
  93      -static  void            append_dmake_cmd(Avo_DoJobMsg *dmake_job_msg, char *orig_cmd_line, int cmd_options);
  94      -static  void            append_job_result_msg(Avo_MToolJobResultMsg *msg, char *outFn, char *errFn);
  95      -static  void            send_job_result_msg(Running rp);
  96      -#endif
  97   87  static  void            delete_running_struct(Running rp);
  98   88  static  Boolean         dependency_conflict(Name target);
  99   89  static  Doname          distribute_process(char **commands, Property line);
 100   90  static  void            doname_subtree(Name target, Boolean do_get, Boolean implicit);
 101   91  static  void            dump_out_file(char *filename, Boolean err);
 102   92  static  void            finish_doname(Running rp);
 103   93  static  void            maybe_reread_make_state(void);
 104   94  static  void            process_next(void);
 105   95  static  void            reset_conditionals(int cnt, Name *targets, Property *locals);
 106   96  static  pid_t           run_rule_commands(char *host, char **commands);
↓ open down ↓ 14 lines elided ↑ open up ↑
 121  111   *      Parameters:
 122  112   *              line            The command group to execute
 123  113   */
 124  114  Doname
 125  115  execute_parallel(Property line, Boolean waitflg, Boolean local)
 126  116  {
 127  117          int                     argcnt;
 128  118          int                     cmd_options = 0;
 129  119          char                    *commands[MAXRULES + 5];
 130  120          char                    *cp;
 131      -#ifdef DISTRIBUTED
 132      -        Avo_DoJobMsg            *dmake_job_msg = NULL;
 133      -#endif
 134  121          Name                    dmake_name;
 135  122          Name                    dmake_value;
 136  123          int                     ignore;
 137  124          Name                    make_machines_name;
 138  125          char                    **p;
 139  126          Property                prop;
 140  127          Doname                  result = build_ok;
 141  128          Cmd_line                rule;
 142  129          Boolean                 silent_flag;
 143  130          Name                    target = line->body.line.target;
↓ open down ↓ 26 lines elided ↑ open up ↑
 170  157                          if (((prop = get_prop(dmake_name->prop, macro_prop)) != NULL) &&
 171  158                              ((dmake_value = prop->body.macro.value) != NULL)) {
 172  159                                  make_machines_name = dmake_value;
 173  160                          } else {
 174  161                                  make_machines_name = NULL;
 175  162                          }
 176  163                          if ((pmake_max_jobs = read_make_machines(make_machines_name)) <= 0) {
 177  164                                  pmake_max_jobs = PMAKE_DEF_MAX_JOBS;
 178  165                          }
 179  166                  }
 180      -#ifdef DISTRIBUTED
 181      -                if (send_mtool_msgs) {
 182      -                        send_rsrc_info_msg(pmake_max_jobs, local_host, user_name);
 183      -                }
 184      -#endif
 185  167          }
 186  168  
 187  169          if ((dmake_mode_type == serial_mode) ||
 188  170              ((dmake_mode_type == parallel_mode) && (waitflg))) {
 189  171                  return (execute_serial(line));
 190  172          }
 191  173  
 192      -#ifdef DISTRIBUTED
 193      -        if (dmake_mode_type == distributed_mode) {
 194      -                if(local) {
 195      -//                      return (execute_serial(line));
 196      -                        waitflg = true;
 197      -                }
 198      -                dmake_job_msg = new Avo_DoJobMsg();
 199      -                dmake_job_msg->setJobId(++job_msg_id);
 200      -                dmake_job_msg->setTarget(target->string_mb);
 201      -                dmake_job_msg->setImmediateOutput(0);
 202      -                called_make = false;
 203      -        } else
 204      -#endif
 205  174          {
 206  175                  p = commands;
 207  176          }
 208  177  
 209  178          argcnt = 0;
 210  179          for (rule = line->body.line.command_used;
 211  180               rule != NULL;
 212  181               rule = rule->next) {
 213  182                  if (posix && (touch || quest) && !rule->always_exec) {
 214  183                          continue;
↓ open down ↓ 14 lines elided ↑ open up ↑
 229  198                  if (rule->command_line->hash.length > 0) {
 230  199                          if (++argcnt == MAXRULES) {
 231  200                                  if (dmake_mode_type == distributed_mode) {
 232  201                                          /* XXX - tell rxm to execute on local host. */
 233  202                                          /* I WAS HERE!!! */
 234  203                                  } else {
 235  204                                          /* Too many rules, run serially instead. */
 236  205                                          return build_serial;
 237  206                                  }
 238  207                          }
 239      -#ifdef DISTRIBUTED
 240      -                        if (dmake_mode_type == distributed_mode) {
 241      -                                /*
 242      -                                 * XXX - set assign_mask to tell rxm
 243      -                                 * to do the following.
 244      -                                 */
 245      -/* From execute_serial():
 246      -                                if (rule->assign) {
 247      -                                        result = build_ok;
 248      -                                        do_assign(rule->command_line, target);
 249      - */
 250      -                                if (0) {
 251      -                                } else if (report_dependencies_level == 0) {
 252      -                                        if (rule->ignore_error) {
 253      -                                                cmd_options |= ignore_mask;
 254      -                                        }
 255      -                                        if (rule->silent) {
 256      -                                                cmd_options |= silent_mask;
 257      -                                        }
 258      -                                        if (rule->command_line->meta) {
 259      -                                                cmd_options |= meta_mask;
 260      -                                        }
 261      -                                        if (rule->make_refd) {
 262      -                                                cmd_options |= make_refd_mask;
 263      -                                        }
 264      -                                        if (do_not_exec_rule) {
 265      -                                                cmd_options |= do_not_exec_mask;
 266      -                                        }
 267      -                                        append_dmake_cmd(dmake_job_msg,
 268      -                                                         rule->command_line->string_mb,
 269      -                                                         cmd_options);
 270      -                                        /* Copying dosys()... */
 271      -                                        if (rule->make_refd) {
 272      -                                                if (waitflg) {
 273      -                                                        dmake_job_msg->setImmediateOutput(1);
 274      -                                                }
 275      -                                                called_make = true;
 276      -                                                if (command_changed &&
 277      -                                                    !wrote_state_file) {
 278      -                                                        write_state_file(0, false);
 279      -                                                        wrote_state_file = true;
 280      -                                                }
 281      -                                        }
 282      -                                }
 283      -                        } else
 284      -#endif
 285  208                          {
 286  209                                  if (rule->silent && !silent) {
 287  210                                          silent_flag = true;
 288  211                                  }
 289  212                                  if (rule->ignore_error) {
 290  213                                          ignore++;
 291  214                                  }
 292  215                                  /* XXX - need to add support for + prefix */
 293  216                                  if (silent_flag || ignore) {
 294  217                                          *p = getmem((silent_flag ? 1 : 0) +
↓ open down ↓ 11 lines elided ↑ open up ↑
 306  229                                          }
 307  230                                          (void) strcpy(cp, rule->command_line->string_mb);
 308  231                                  } else {
 309  232                                          *p++ = rule->command_line->string_mb;
 310  233                                  }
 311  234                          }
 312  235                  }
 313  236          }
 314  237          if ((argcnt == 0) ||
 315  238              (report_dependencies_level > 0)) {
 316      -#ifdef DISTRIBUTED
 317      -                if (dmake_job_msg) {
 318      -                        delete dmake_job_msg;
 319      -                }
 320      -#endif
 321  239                  return build_ok;
 322  240          }
 323      -#ifdef DISTRIBUTED
 324      -        if (dmake_mode_type == distributed_mode) {
 325      -                // Send  a DoJob message to the rxm process.
 326      -                distribute_rxm(dmake_job_msg);
 327      -
 328      -                // Wait for an acknowledgement.
 329      -                Avo_AcknowledgeMsg *ackMsg = getAcknowledgeMsg();
 330      -                if (ackMsg) {
 331      -                        delete ackMsg;
 332      -                }
 333      -
 334      -                if (waitflg) {
 335      -                        // Wait for, and process a job result.
 336      -                        result = await_dist(waitflg);
 337      -                        if (called_make) {
 338      -                                maybe_reread_make_state();
 339      -                        }
 340      -                        check_state(temp_file_name);
 341      -                        if (result == build_failed) {
 342      -                                if (!continue_after_error) {
 343      -
 344      -#ifdef PRINT_EXIT_STATUS
 345      -                                        warning(NOCATGETS("I'm in execute_parallel. await_dist() returned build_failed"));
 346      -#endif
 347      -
 348      -                                        fatal(catgets(catd, 1, 252, "Command failed for target `%s'"),
 349      -                                              target->string_mb);
 350      -                                }
 351      -                                /*
 352      -                                 * Make sure a failing command is not
 353      -                                 * saved in .make.state.
 354      -                                 */
 355      -                                line->body.line.command_used = NULL;
 356      -                        }
 357      -                        if (temp_file_name != NULL) {
 358      -                                free_name(temp_file_name);
 359      -                        }
 360      -                        temp_file_name = NULL;
 361      -                        Property spro = get_prop(sunpro_dependencies->prop, macro_prop);
 362      -                        if(spro != NULL) {
 363      -                                Name val = spro->body.macro.value;
 364      -                                if(val != NULL) {
 365      -                                        free_name(val);
 366      -                                        spro->body.macro.value = NULL;
 367      -                                }
 368      -                        }
 369      -                        spro = get_prop(sunpro_dependencies->prop, env_mem_prop);
 370      -                        if(spro) {
 371      -                                char *val = spro->body.env_mem.value;
 372      -                                if(val != NULL) {
 373      -                                        retmem_mb(val);
 374      -                                        spro->body.env_mem.value = NULL;
 375      -                                }
 376      -                        }
 377      -                        return result;
 378      -                } else {
 379      -                        parallel_process_cnt++;
 380      -                        return build_running;
 381      -                }
 382      -        } else
 383      -#endif
 384  241          {
 385  242                  *p = NULL;
 386  243  
 387  244                  Doname res = distribute_process(commands, line);
 388  245                  if (res == build_running) {
 389  246                          parallel_process_cnt++;
 390  247                  }
 391  248  
 392  249                  /*
 393  250                   * Return only those memory that were specially allocated
↓ open down ↓ 2 lines elided ↑ open up ↑
 396  253                  for (int i = 0; commands[i] != NULL; i++) {
 397  254                          if ((commands[i][0] == (int) at_char) ||
 398  255                              (commands[i][0] == (int) hyphen_char)) {
 399  256                                  retmem_mb(commands[i]);
 400  257                          }
 401  258                  }
 402  259                  return res;
 403  260          }
 404  261  }
 405  262  
 406      -#ifdef DISTRIBUTED
 407      -/*
 408      - *      append_dmake_cmd()
 409      - *
 410      - *      Replaces all escaped newline's (\<cr>)
 411      - *        in the original command line with space's,
 412      - *        then append the new command line to the DoJobMsg object.
 413      - */
 414      -static void
 415      -append_dmake_cmd(Avo_DoJobMsg *dmake_job_msg,
 416      -                 char *orig_cmd_line,
 417      -                 int cmd_options)
 418      -{
 419      -/*
 420      -        Avo_DmakeCommand        *tmp_dmake_command;
 421      -
 422      -        tmp_dmake_command = new Avo_DmakeCommand(orig_cmd_line, cmd_options);
 423      -        dmake_job_msg->appendCmd(tmp_dmake_command);
 424      -        delete tmp_dmake_command;
 425      - */
 426      -        dmake_job_msg->appendCmd(new Avo_DmakeCommand(orig_cmd_line, cmd_options));
 427      -}
 428      -#endif
 429  263  
 430  264  #ifdef TEAMWARE_MAKE_CMN
 431  265  #define MAXJOBS_ADJUST_RFE4694000
 432  266  
 433  267  #ifdef MAXJOBS_ADJUST_RFE4694000
 434  268  
 435  269  #include <unistd.h>     /* sysconf(_SC_NPROCESSORS_ONLN) */
 436  270  #include <sys/ipc.h>            /* ftok() */
 437  271  #include <sys/shm.h>            /* shmget(), shmat(), shmdt(), shmctl() */
 438  272  #include <semaphore.h>          /* sem_init(), sem_trywait(), sem_post(), sem_destroy() */
↓ open down ↓ 349 lines elided ↑ open up ↑
 788  622                          }
 789  623                  }
 790  624                  break;
 791  625          default:
 792  626                  while (parallel_process_cnt >= pmake_max_jobs) {
 793  627                          await_parallel(false);
 794  628                          finish_children(true);
 795  629                  }
 796  630          }
 797  631  #endif /* TEAMWARE_MAKE_CMN && MAXJOBS_ADJUST_RFE4694000 */
 798      -#ifdef DISTRIBUTED
 799      -        if (send_mtool_msgs) {
 800      -                send_job_start_msg(line);
 801      -        }
 802      -#endif
 803      -#ifdef DISTRIBUTED
 804      -        setvar_envvar((Avo_DoJobMsg *)NULL);
 805      -#else
 806  632          setvar_envvar();
 807      -#endif
 808  633          /*
 809  634           * Tell the user what DMake is doing.
 810  635           */
 811  636          if (!silent && output_mode != txt2_mode) {
 812  637                  /*
 813  638                   * Print local_host --> x job(s).
 814  639                   */
 815  640                  (void) fprintf(stdout,
 816  641                                 catgets(catd, 1, 325, "%s --> %d %s\n"),
 817  642                                 local_host,
↓ open down ↓ 120 lines elided ↑ open up ↑
 938  763   *
 939  764   *      Parameters:
 940  765   *
 941  766   *      Global variables used:
 942  767   *              running_list    The list of running processes
 943  768   */
 944  769  void
 945  770  finish_running(void)
 946  771  {
 947  772          while (running_list != NULL) {
 948      -#ifdef DISTRIBUTED
 949      -                if (dmake_mode_type == distributed_mode) {
 950      -                        if ((just_did_subtree) ||
 951      -                            (parallel_process_cnt == 0)) {
 952      -                                just_did_subtree = false;
 953      -                        } else {
 954      -                                (void) await_dist(false);
 955      -                                finish_children(true);
 956      -                        }
 957      -                } else
 958      -#endif
 959  773                  {
 960  774                          await_parallel(false);
 961  775                          finish_children(true);
 962  776                  }
 963  777                  if (running_list != NULL) {
 964  778                          process_next();
 965  779                  }
 966  780          }
 967  781  }
 968  782  
↓ open down ↓ 143 lines elided ↑ open up ↑
1112  926                          if (rp->state == build_subtree) {
1113  927                                  if (!dependency_conflict(rp->target)) {
1114  928                                          *rp_prev = rp->next;
1115  929                                          if (rp->next == NULL) {
1116  930                                                  running_tail = rp_prev;
1117  931                                          }
1118  932                                          recursion_level = rp->recursion_level;
1119  933                                          doname_subtree(rp->target,
1120  934                                                         rp->do_get,
1121  935                                                         rp->implicit);
1122      -#ifdef DISTRIBUTED
1123      -                                        just_did_subtree = true;
1124      -#endif
1125  936                                          quiescent = false;
1126  937                                          delete_running_struct(rp);
1127  938                                          goto start_loop_3;
1128  939                                  } else {
1129  940                                          subtree_target = rp_prev;
1130  941                                          rp_prev = &rp->next;
1131  942                                  }
1132  943                          } else {
1133  944                                  rp_prev = &rp->next;
1134  945                          }
↓ open down ↓ 14 lines elided ↑ open up ↑
1149  960                                          subtree_conflict2->string_mb,
1150  961                                          rp->target->string_mb,
1151  962                                          subtree_conflict->string_mb);
1152  963                          }
1153  964                          *subtree_target = (*subtree_target)->next;
1154  965                          if (rp->next == NULL) {
1155  966                                  running_tail = subtree_target;
1156  967                          }
1157  968                          recursion_level = rp->recursion_level;
1158  969                          doname_subtree(rp->target, rp->do_get, rp->implicit);
1159      -#ifdef DISTRIBUTED
1160      -                        just_did_subtree = true;
1161      -#endif
1162  970                          delete_running_struct(rp);
1163  971                  }
1164  972          }
1165  973  }
1166  974  
1167  975  /*
1168  976   *      set_conditionals(cnt, targets)
1169  977   *
1170  978   *      Sets the conditional macros for the targets given in the array of
1171  979   *      targets.  The old macro values are returned in an array of
↓ open down ↓ 251 lines elided ↑ open up ↑
1423 1231                          }
1424 1232                          if ((line2 = rp->command) == NULL) {
1425 1233                                  line2 = get_prop(rp->target->prop, line_prop);
1426 1234                          }
1427 1235                          if (dmake_mode_type == distributed_mode) {
1428 1236                                  if (rp->make_refd) {
1429 1237                                          maybe_reread_make_state();
1430 1238                                  }
1431 1239                          } else {
1432 1240                                  /*
1433      -                                 * Send an Avo_MToolJobResultMsg to maketool.
1434      -                                 */
1435      -#ifdef DISTRIBUTED
1436      -                                if (send_mtool_msgs) {
1437      -                                        send_job_result_msg(rp);
1438      -                                }
1439      -#endif
1440      -                                /*
1441 1241                                   * Check if there were any job output
1442 1242                                   * from the parallel build.
1443 1243                                   */
1444 1244                                  if (rp->stdout_file != NULL) {
1445 1245                                          if (stat(rp->stdout_file, &out_buf) < 0) {
1446 1246                                                  fatal(catgets(catd, 1, 130, "stat of %s failed: %s"),
1447 1247                                                        rp->stdout_file,
1448 1248                                                        errmsg(errno));
1449 1249                                          }
1450 1250                                          if ((line2 != NULL) &&
↓ open down ↓ 287 lines elided ↑ open up ↑
1738 1538          rp->implicit = implicit;
1739 1539          rp->auto_count = auto_count;
1740 1540          if (auto_count > 0) {
1741 1541                  rp->automatics = (Name *) getmem(auto_count * sizeof (Name));
1742 1542                  for (p = rp->automatics; auto_count > 0; auto_count--) {
1743 1543                          *p++ = *automatics++;
1744 1544                  }
1745 1545          } else {
1746 1546                  rp->automatics = NULL;
1747 1547          }
1748      -#ifdef DISTRIBUTED
1749      -        if (dmake_mode_type == distributed_mode) {
1750      -                rp->make_refd = called_make;
1751      -                called_make = false;
1752      -        } else
1753      -#endif
1754 1548          {
1755 1549                  rp->pid = process_running;
1756 1550                  process_running = -1;
1757 1551                  childPid = -1;
1758 1552          }
1759 1553          rp->job_msg_id = job_msg_id;
1760 1554          rp->stdout_file = stdout_file;
1761 1555          rp->stderr_file = stderr_file;
1762 1556          rp->temp_file = temp_file_name;
1763 1557          rp->redo = false;
↓ open down ↓ 338 lines elided ↑ open up ↑
2102 1896                                          false,
2103 1897                                          false,
2104 1898                                          false,
2105 1899                                          false,
2106 1900                                          false,
2107 1901                                          true);
2108 1902                  trace_reader = false;
2109 1903          }
2110 1904  }
2111 1905  
2112      -#ifdef DISTRIBUTED
2113      -/*
2114      - * Create and send an Avo_MToolJobResultMsg.
2115      - */
2116      -static void
2117      -send_job_result_msg(Running rp)
2118      -{
2119      -        Avo_MToolJobResultMsg   *msg;
2120      -        RWCollectable           *xdr_msg;
2121      -
2122      -        msg = new Avo_MToolJobResultMsg();
2123      -        msg->setResult(rp->job_msg_id,
2124      -                       (rp->state == build_ok) ? 0 : 1,
2125      -                       DONE);
2126      -        append_job_result_msg(msg,
2127      -                                rp->stdout_file,
2128      -                                rp->stderr_file);
2129      -
2130      -        xdr_msg = (RWCollectable *)msg;
2131      -        xdr(get_xdrs_ptr(), xdr_msg);
2132      -        (void) fflush(get_mtool_msgs_fp());
2133      -
2134      -        delete msg;
2135      -}
2136      -
2137      -/*
2138      - * Append the stdout/err to Avo_MToolJobResultMsg.
2139      - */
2140      -static void
2141      -append_job_result_msg(Avo_MToolJobResultMsg *msg, char *outFn, char *errFn)
2142      -{
2143      -        FILE            *fp;
2144      -        char            line[MAXPATHLEN];
2145      -
2146      -        fp = fopen(outFn, "r");
2147      -        if (fp == NULL) {
2148      -                /* Hmmm... what should we do here? */
2149      -                return;
2150      -        }
2151      -        while (fgets(line, MAXPATHLEN, fp) != NULL) {
2152      -                if (line[strlen(line) - 1] == '\n') {
2153      -                        line[strlen(line) - 1] = '\0';
2154      -                }
2155      -                msg->appendOutput(AVO_STRDUP(line));
2156      -        }
2157      -        (void) fclose(fp);
2158      -}
2159      -#endif
2160 1906  
2161 1907  static void
2162 1908  delete_running_struct(Running rp)
2163 1909  {
2164 1910          if ((rp->conditional_cnt > 0) &&
2165 1911              (rp->conditional_targets != NULL)) {
2166 1912                  retmem_mb((char *) rp->conditional_targets);
2167 1913          }
2168 1914  /**/
2169 1915          if ((rp->auto_count > 0) &&
↓ open down ↓ 16 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX