=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/job.c,v retrieving revision 1.82 retrieving revision 1.83 diff -c -r1.82 -r1.83 *** src/usr.bin/make/job.c 2007/09/23 09:41:11 1.82 --- src/usr.bin/make/job.c 2007/09/23 09:44:39 1.83 *************** *** 1,5 **** /* $OpenPackages$ */ ! /* $OpenBSD: job.c,v 1.82 2007/09/23 09:41:11 espie Exp $ */ /* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */ /* --- 1,5 ---- /* $OpenPackages$ */ ! /* $OpenBSD: job.c,v 1.83 2007/09/23 09:44:39 espie Exp $ */ /* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */ /* *************** *** 160,167 **** short flags; /* Flags to control treatment of job */ #define JOB_IGNERR 0x001 /* Ignore non-zero exits */ #define JOB_SILENT 0x002 /* no output */ ! #define JOB_SPECIAL 0x004 /* Target is a special one. i.e. run it locally ! * if we can't export it and maxLocal is 0 */ #define JOB_IGNDOTS 0x008 /* Ignore "..." lines when processing * commands */ #define JOB_FIRST 0x020 /* Job is first job for the node */ --- 160,166 ---- short flags; /* Flags to control treatment of job */ #define JOB_IGNERR 0x001 /* Ignore non-zero exits */ #define JOB_SILENT 0x002 /* no output */ ! #define JOB_SPECIAL 0x004 /* Target is a special one. */ #define JOB_IGNDOTS 0x008 /* Ignore "..." lines when processing * commands */ #define JOB_FIRST 0x020 /* Job is first job for the node */ *************** *** 223,237 **** static int maxJobs; /* The most children we can run at once */ ! static int maxLocal; /* The most local ones we can have */ ! static int nJobs = 0; /* The number of children currently running */ ! static int nLocal; /* The number of local children */ static LIST jobs; /* The structures that describe them */ static bool jobFull; /* Flag to tell when the job table is full. It ! * is set true when (1) the total number of ! * running jobs equals the maximum allowed or ! * (2) a job can only be run locally, but ! * nLocal equals maxLocal */ static fd_set *outputsp; /* Set of descriptors of pipes connected to * the output channels of children */ static int outputsn; --- 222,231 ---- static int maxJobs; /* The most children we can run at once */ ! static int nJobs; /* The number of children currently running */ static LIST jobs; /* The structures that describe them */ static bool jobFull; /* Flag to tell when the job table is full. It ! * is set true when nJobs equals maxJobs */ static fd_set *outputsp; /* Set of descriptors of pipes connected to * the output channels of children */ static int outputsn; *************** *** 842,848 **** (long)job->pid); (void)fflush(stdout); } - nLocal++; if (nJobs == maxJobs) { jobFull = true; if (DEBUG(JOB)) { --- 836,841 ---- *************** *** 1065,1071 **** } } - nLocal += 1; /* * Now the job is actually running, add it to the table. */ --- 1058,1063 ---- *************** *** 1133,1139 **** job->node->name); (void)fflush(stdout); } ! if (nLocal >= maxLocal && !(job->flags & JOB_SPECIAL)) { /* * Can't be exported and not allowed to run locally -- * put it back on the hold queue and mark the table --- 1125,1131 ---- job->node->name); (void)fflush(stdout); } ! if (nJobs >= maxJobs && !(job->flags & JOB_SPECIAL)) { /* * Can't be exported and not allowed to run locally -- * put it back on the hold queue and mark the table *************** *** 1169,1179 **** (void)fprintf(stdout, "Resuming %s...", job->node->name); (void)fflush(stdout); } ! if ((nLocal < maxLocal || ((job->flags & JOB_SPECIAL) && ! maxLocal == 0)) && nJobs != maxJobs) { /* * If we haven't reached the concurrency limit already ! * (or maxLocal is 0), it's ok to resume the job. */ bool error; int status; --- 1161,1171 ---- (void)fprintf(stdout, "Resuming %s...", job->node->name); (void)fflush(stdout); } ! if ((nJobs < maxJobs || ((job->flags & JOB_SPECIAL) && ! maxJobs == 0)) && nJobs != maxJobs) { /* * If we haven't reached the concurrency limit already ! * (or maxJobs is 0), it's ok to resume the job. */ bool error; int status; *************** *** 1247,1253 **** Job *job; /* new job descriptor */ char *argv[4]; /* Argument vector to shell */ bool cmdsOK; /* true if the nodes commands were all right */ - bool local; /* Set true if the job was run locally */ bool noExec; /* Set true if we decide not to run the job */ if (previous != NULL) { --- 1239,1244 ---- *************** *** 1466,1483 **** (void)fcntl(job->outPipe, F_SETFD, 1); } ! local = true; ! ! if (local && nLocal >= maxLocal && !(job->flags & JOB_SPECIAL) && ! maxLocal != 0) { /* * The job can only be run locally, but we've hit the limit of * local concurrency, so put the job on hold until some other * job finishes. Note that the special jobs (.BEGIN, .INTERRUPT * and .END) may be run locally even when the local limit has ! * been reached (e.g. when maxLocal == 0), though they will be * exported if at all possible. In addition, any target marked ! * with .NOEXPORT will be run locally if maxLocal is 0. */ jobFull = true; --- 1457,1472 ---- (void)fcntl(job->outPipe, F_SETFD, 1); } ! if (nJobs >= maxJobs && !(job->flags & JOB_SPECIAL) && ! maxJobs != 0) { /* * The job can only be run locally, but we've hit the limit of * local concurrency, so put the job on hold until some other * job finishes. Note that the special jobs (.BEGIN, .INTERRUPT * and .END) may be run locally even when the local limit has ! * been reached (e.g. when maxJobs == 0), though they will be * exported if at all possible. In addition, any target marked ! * with .NOEXPORT will be run locally if maxJobs is 0. */ jobFull = true; *************** *** 1488,1494 **** job->flags |= JOB_RESTART; Lst_AtEnd(&stoppedJobs, job); } else { ! if (nLocal >= maxLocal && local) { /* * If we're running this job locally as a special case * (see above), at least say the table is full. --- 1477,1483 ---- job->flags |= JOB_RESTART; Lst_AtEnd(&stoppedJobs, job); } else { ! if (nJobs >= maxJobs) { /* * If we're running this job locally as a special case * (see above), at least say the table is full. *************** *** 1729,1735 **** /* * Don't even bother if we know there's no one around. */ ! if (nLocal == 0) { return; } --- 1718,1724 ---- /* * Don't even bother if we know there's no one around. */ ! if (nJobs == 0) { return; } *************** *** 1768,1774 **** (void)fflush(stdout); } jobFull = false; - nLocal--; } JobFinish(job, &status); --- 1757,1762 ---- *************** *** 1851,1857 **** *----------------------------------------------------------------------- */ void ! Job_Init(int maxproc, int maxlocal) { int tfd; --- 1839,1845 ---- *----------------------------------------------------------------------- */ void ! Job_Init(int maxproc) { int tfd; *************** *** 1864,1872 **** Static_Lst_Init(&jobs); Static_Lst_Init(&stoppedJobs); maxJobs = maxproc; - maxLocal = maxlocal; nJobs = 0; - nLocal = 0; jobFull = false; aborting = 0; --- 1852,1858 ----