diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-08-05 14:18:13 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-02-11 11:59:16 +0100 |
commit | 61cf68fb482b401a9f772aca768efc7c46d2038d (patch) | |
tree | e7c197cbfcf979c2684beee666bd31078b576e11 | |
parent | c29d3750885c598cd015a638a322afa36d636d27 (diff) |
RID_Alloc: Fix locking in getornull and free early returns
Those missing unlocks were preventing the editor from starting.
-rw-r--r-- | core/rid_owner.h | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/core/rid_owner.h b/core/rid_owner.h index 3c2e61f677..26807e9a5e 100644 --- a/core/rid_owner.h +++ b/core/rid_owner.h @@ -109,6 +109,9 @@ public: uint64_t id = p_rid.get_id(); uint32_t idx = uint32_t(id & 0xFFFFFFFF); if (unlikely(idx >= max_alloc)) { + if (THREAD_SAFE) { + spin_lock.unlock(); + } return NULL; } @@ -116,7 +119,10 @@ public: uint32_t idx_element = idx % elements_in_chunk; uint32_t validator = uint32_t(id >> 32); - if (validator_chunks[idx_chunk][idx_element] != validator) { + if (unlikely(validator_chunks[idx_chunk][idx_element] != validator)) { + if (THREAD_SAFE) { + spin_lock.unlock(); + } return NULL; } @@ -166,13 +172,23 @@ public: uint64_t id = p_rid.get_id(); uint32_t idx = uint32_t(id & 0xFFFFFFFF); - ERR_FAIL_COND(idx >= max_alloc); + if (unlikely(idx >= max_alloc)) { + if (THREAD_SAFE) { + spin_lock.unlock(); + } + ERR_FAIL(); + } uint32_t idx_chunk = idx / elements_in_chunk; uint32_t idx_element = idx % elements_in_chunk; uint32_t validator = uint32_t(id >> 32); - ERR_FAIL_COND(validator_chunks[idx_chunk][idx_element] != validator); + if (unlikely(validator_chunks[idx_chunk][idx_element] != validator)) { + if (THREAD_SAFE) { + spin_lock.unlock(); + } + ERR_FAIL(); + } chunks[idx_chunk][idx_element].~T(); validator_chunks[idx_chunk][idx_element] = 0xFFFFFFFF; // go invalid |