Cyclic dependency checker: don't give up token in common case.
The way the code was written, we'd give up our token, detect a cyclic dependency, and then try to get our token back before exiting. Even with -j1, the temporary token release allowed any parent up the tree to continue running jobs, so it would take an arbitrary amount of time before we could exit (and report an error code to the parent). There was no visible symptom of this except that, with -j1, t/355-deps-cyclic would not finish until some of the later tests finished, which was surprising. To fix it, let's just check for a cyclic dependency first, then release the token only once we're sure things are sane.
This commit is contained in:
parent
427deb199f
commit
bb80118298
3 changed files with 19 additions and 15 deletions
14
builder.py
14
builder.py
|
|
@ -353,18 +353,18 @@ def main(targets, shouldbuildfunc):
|
|||
backoff *= 2
|
||||
if vars.DEBUG_LOCKS:
|
||||
warn('%s (WAITING)\n' % _nice(t))
|
||||
try:
|
||||
lock.check()
|
||||
except state.CyclicDependencyError:
|
||||
err('cyclic dependency while building %s\n' % _nice(t))
|
||||
retcode[0] = 208
|
||||
return retcode[0]
|
||||
# this sequence looks a little silly, but the idea is to
|
||||
# give up our personal token while we wait for the lock to
|
||||
# be released; but we should never run get_token() while
|
||||
# holding a lock, or we could cause deadlocks.
|
||||
jwack.release_mine()
|
||||
try:
|
||||
lock.waitlock()
|
||||
except state.CyclicDependencyError:
|
||||
err('cyclic dependency while building %s\n' % _nice(t))
|
||||
jwack.get_token(t)
|
||||
retcode[0] = 208
|
||||
return retcode[0]
|
||||
lock.waitlock()
|
||||
lock.unlock()
|
||||
jwack.get_token(t)
|
||||
lock.trylock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue