From 7b8cfc67fe344a43e9022a92b3e62a78d66afa9c Mon Sep 17 00:00:00 2001 From: Jaden Weiss Date: Fri, 23 Feb 2018 17:56:31 -0500 Subject: [PATCH] better handling of deadlock --- lbuild/ruletable.lua | 11 +++++++++++ lbuild/runner.lua | 3 +++ 2 files changed, 14 insertions(+) diff --git a/lbuild/ruletable.lua b/lbuild/ruletable.lua index 362101a..4a1a6e4 100644 --- a/lbuild/ruletable.lua +++ b/lbuild/ruletable.lua @@ -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 diff --git a/lbuild/runner.lua b/lbuild/runner.lua index bc3d1fa..5efa600 100644 --- a/lbuild/runner.lua +++ b/lbuild/runner.lua @@ -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