Release the jwack token when doing a synchronous lock wait.
Although we were deadlock-free before, under some circumstances we'd end up holding a perfectly good token while in sync wait; that would reduce our parallelism for no good reason. So give back our tokens before waiting for anybody else.
This commit is contained in:
parent
f6d11d5411
commit
c4be0050f7
2 changed files with 19 additions and 1 deletions
10
builder.py
10
builder.py
|
|
@ -273,10 +273,18 @@ def main(targets, shouldbuildfunc):
|
|||
fid,t = locked.pop(0)
|
||||
lock = state.Lock(fid)
|
||||
lock.trylock()
|
||||
if not lock.owned:
|
||||
while not lock.owned:
|
||||
if vars.DEBUG_LOCKS:
|
||||
warn('%s (WAITING)\n' % _nice(t))
|
||||
# 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()
|
||||
lock.waitlock()
|
||||
lock.unlock()
|
||||
jwack.get_token(t)
|
||||
lock.trylock()
|
||||
assert(lock.owned)
|
||||
if vars.DEBUG_LOCKS:
|
||||
log('%s (...unlocked!)\n' % _nice(t))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue