Skip to content

Commit

Permalink
better handling of deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
niaow committed Feb 23, 2018
1 parent af58790 commit 7b8cfc6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lbuild/ruletable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,15 @@ ruletable:addgenerator(function(name)
return nil
end)

runner.ondeadlock = function()
print("Deadlock!")
print("Incomplete operations:")
for i, v in pairs(ruletbl.rules) do
if v.state ~= "done" and v.state then
print(string.format("\t%s (%s)", i, v.state))
end
end
error("deadlock")
end

return ruletable
3 changes: 3 additions & 0 deletions lbuild/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ function runner:wait()
op.pid = nil
self.n = self.n - 1
else
if runner.ondeadlock then
runner.ondeadlock()
end
error("Nothing running")
end
end
Expand Down

0 comments on commit 7b8cfc6

Please sign in to comment.