diff options
| author | ruki <[email protected]> | 2024-07-02 22:37:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-07-02 22:37:43 +0800 |
| commit | 97b32c8f5dc84c305bd494a533f8fcc1fea73132 (patch) | |
| tree | fd5b83274df04eb1700139ab975f993eb6c9e401 | |
| parent | 9fd0a10896cc92a94afb07675c75e7bea86bf83d (diff) | |
lock to check platform/toolchains
| -rw-r--r-- | xmake/core/platform/platform.lua | 10 |
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 |
