tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: make: remove wantToken and skip polling tokenWaitJob



On May 12, 10:14am, sjg%juniper.net@localhost ("Simon J. Gerraty") wrote:
-- Subject: Re: make: remove wantToken and skip polling tokenWaitJob

| diff -r 663b16a373e5 bmake/job.c
| --- a/bmake/job.c	Sun Apr 15 11:34:25 2018 -0700
| +++ b/bmake/job.c	Fri May 11 17:03:17 2018 -0700
| @@ -2963,14 +2958,16 @@
|      count = read(tokenWaitJob.inPipe, &tok, 1);
|      if (count == 0)
|  	Fatal("eof on job pipe!");
| -    if (count < 0 && jobTokensRunning != 0) {
| +    if (count < 0) {
|  	if (errno != EAGAIN) {
|  	    Fatal("job pipe read: %s", strerror(errno));
|  	}
|  	if (DEBUG(JOB))
|  	    fprintf(debug_file, "(%d) blocked for token\n", getpid());
| -	wantToken = 1;
| -	return FALSE;
| +	if (!jobTokensRunning)
| +	    sleep(1);			/* avoid busy wait */
| +	else
| +	    return FALSE;

I would write this as:
	if (jobTokensRunning)
	    return FALSE;
	sleep(1);			/* avoid busy wait */

Otherwise let's give it a whirl.

christos


Home | Main Index | Thread Index | Old Index