NetBSD-Bugs archive

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

Re: bin/47524: make(1) loops in Job_CatchOutput()



The following reply was made to PR bin/47524; it has been noted by GNATS.

From: David Laight <david%l8s.co.uk@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: bin/47524: make(1) loops in Job_CatchOutput()
Date: Tue, 5 Feb 2013 22:34:17 +0000

 On Tue, Feb 05, 2013 at 11:46:07PM +0200, Andreas Gustafsson wrote:
 > +    do {
 > +    nready = poll(fds + 1 - wantToken, nfds - 1 + wantToken, POLL_MSEC);
 > +    } while (nready < 0 && errno == EINTR);
 > +    if (nready < 0)
 > +    Punt("poll: %s", strerror(errno));
 > +
 > +    if (nready == 0 || readyfd(&childExitJob)) {
 > +    if (nready > 0) {
 > +        char token = 0;
 > +        int count;
 > +        nready -= 1;
 > +        count = read(childExitJob.inPipe, &token, 1);
 > +        if (count < 0) {
 > +            Punt("token pipe read: %s", strerror(errno));
 > +        } else if (count == 0) {
 > +            Punt("unexpected eof on token pipe");
 > +        } else { /* count > 0 */
 > +            assert(count == 1);
 > +             if (token == DO_JOB_RESUME[0])
 > +                 /* Complete relay requested from our SIGCONT handler */
 > +                 JobRestartJobs();
 > +        }
 > +    }
 
 That is a riduculous number of tests, you can't see what the code
 is doing any more.
 
 Indeed, you now error out if the read(childExitJob.inPipe, &token, 1)
 manages to fail to return some data. I wouldn't like to guarantee
 that all systems don't have some point where such a read can get
 interrupted (even though non-blocking) before committing to copy
 a byte to userspace.
 
 The 'token = 0' assignent is enough that it doesn't matter whether
 the read fails of not.
 
 Apart from issues with poll() actually returning a read error - so
 it doesn't block next time around either, it really doesn't matter
 why the code woke up.
 
 I might even have decided that if the poll() call was interrupted
 we might as well act as it the childExitJob pipe had a character in it.
 
        David
 
 -- 
 David Laight: david%l8s.co.uk@localhost
 


Home | Main Index | Thread Index | Old Index