20 #include <ndbd_exit_codes.h>
25 memset(
this, 0,
sizeof(*
this));
26 m_current_pos = WOPage::WOPAGE_WORDS;
34 m_record_info.m_size = ((ri.m_size + 3) >> 2);
35 m_record_info.m_offset_magic = ((ri.m_offset_magic + 3) >> 2);
37 ndbout_c(
"WOPool::init(%x, %d)",ri.m_type_id, m_record_info.m_size);
44 Uint32 page_no = RNIL;
49 m_current_page->m_ref_count = m_current_ref_count;
53 m_current_ref_count = 0;
54 m_current_page_no = page_no;
55 m_current_page =
page;
56 page->m_type_id = m_record_info.m_type_id;
57 bool ret = seize(ptr);
65 WOPool::release_not_current(
Ptr<void> ptr)
67 WOPage* page = (
WOPage*)(UintPtr(ptr.p) & ~(GLOBAL_PAGE_SIZE - 1));
68 Uint32 cnt = page->m_ref_count;
69 Uint32
type = page->m_type_id;
70 Uint32 ri_type = m_record_info.m_type_id;
71 if (likely(cnt && type == ri_type))
78 page->m_ref_count = cnt - 1;
82 handle_inconsistent_release(ptr);
86 WOPool::handle_invalid_release(
Ptr<void> ptr)
90 Uint32 pos = ptr.i & POOL_RECORD_MASK;
91 Uint32 pageI = ptr.i >> POOL_RECORD_BITS;
92 Uint32 * record_ptr_p = (Uint32*)ptr.p;
93 Uint32 * record_ptr_i = (m_memroot+pageI)->m_data + pos;
95 Uint32 magic = * (record_ptr_p + m_record_info.m_offset_magic);
97 "Invalid memory release: ptr (%x %p %p) magic: (%.8x %.8x) memroot: %p page: %x",
98 ptr.i, ptr.p, record_ptr_i, magic, m_record_info.m_type_id,
100 (m_memroot+pageI)->m_type_id);
106 WOPool::handle_invalid_get_ptr(Uint32 ptrI)
110 Uint32 pos = ptrI & POOL_RECORD_MASK;
111 Uint32 pageI = ptrI >> POOL_RECORD_BITS;
112 Uint32 * record_ptr_i = (m_memroot+pageI)->m_data + pos;
114 Uint32 magic = * (record_ptr_i + m_record_info.m_offset_magic);
116 "Invalid memory access: ptr (%x %p) magic: (%.8x %.8x) memroot: %p page: %x",
117 ptrI, record_ptr_i, magic, m_record_info.m_type_id,
119 (m_memroot+pageI)->m_type_id);
125 WOPool::handle_inconsistent_release(
Ptr<void> ptr)
127 WOPage* page = (
WOPage*)(UintPtr(ptr.p) & ~(GLOBAL_PAGE_SIZE - 1));
128 Uint32 cnt = page->m_ref_count;
129 Uint32 type = page->m_type_id;
130 Uint32 ri_type = m_record_info.m_type_id;
135 "Memory corruption: ptr (%x %p) page (%d %x %x)",
136 ptr.i, ptr.p, cnt, type, ri_type);