summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-07-02 13:52:15 +0800
committerGitHub <[email protected]>2024-07-02 13:52:15 +0800
commit7b7d1ade7075b2a3673ae1cfccabba628c7f9f86 (patch)
treeef48fc27850b318ccb71bf2413192f043c6a49b1
parent09ba53f5930c2ab20ad5dfcb5391226ad5e7aadf (diff)
parent97b32c8f5dc84c305bd494a533f8fcc1fea73132 (diff)
Merge pull request #5290 from xmake-io/toolchain
lock to check platform/toolchains
-rw-r--r--xmake/core/platform/platform.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua
index 54ec35747..1b2ba19e3 100644
--- a/xmake/core/platform/platform.lua
+++ b/xmake/core/platform/platform.lua
@@ -33,6 +33,7 @@ local memcache = require("cache/memcache")
local sandbox = require("sandbox/sandbox")
local config = require("project/config")
local global = require("base/global")
+local scheduler = require("sandbox/modules/import/core/base/scheduler")
-- new an instance
function _instance.new(name, arch, info)
@@ -236,8 +237,15 @@ end
-- do check
function _instance:check()
+ -- @see https://github.com/xmake-io/xmake/issues/4645#issuecomment-2201036943
+ -- @note avoid check it in the same time leading to deadlock if running in the coroutine
+ local lockname = tostring(self)
+ scheduler.co_lock(lockname)
+
+ -- this platform has been check?
local checked = self:_memcache():get("checked")
if checked ~= nil then
+ scheduler.co_unlock(lockname)
return checked
end
@@ -263,12 +271,14 @@ function _instance:check()
end
if #toolchains == 0 then
self:_memcache():set("checked", false)
+ scheduler.co_unlock(lockname)
return false, "toolchains not found!"
end
-- save valid toolchains
config.set("__toolchains_" .. self:name() .. "_" .. self:arch(), toolchains_valid)
self:_memcache():set("checked", true)
+ scheduler.co_unlock(lockname)
return true
end