Skip to content

Commit

Permalink
ClassInfo, bugfix: class id will be messy under multiple workers.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Sep 27, 2019
1 parent b0fed7b commit 9f2c881
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fibjs/include/ClassInfo.h
Expand Up @@ -302,11 +302,13 @@ class ClassInfo {
private:
cache* _init(Isolate* isolate)
{
static exlib::atomic m_gid;

if (m_id < 0)
m_id = (int32_t)isolate->m_classInfo.size();
m_id = (int32_t)m_gid.inc();

void* p = NULL;
while ((int32_t)isolate->m_classInfo.size() < m_id + 1)
while ((int32_t)isolate->m_classInfo.size() < m_id)
isolate->m_classInfo.append(p);

cache* _cache = (cache*)isolate->m_classInfo[m_id];
Expand Down

0 comments on commit 9f2c881

Please sign in to comment.