Skip to content

Commit 57a62bc

Browse files
committed
fix some bugs
1 parent e3c8f8e commit 57a62bc

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/ipc.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct chunk_info_t {
112112
}
113113

114114
ipc::byte_t* at(std::size_t chunk_size, ipc::storage_id_t id) noexcept {
115-
assert(id >= 0);
115+
if (id < 0) return nullptr;
116116
return chunks_mem() + (chunk_size * id);
117117
}
118118
};
@@ -137,13 +137,11 @@ auto& chunk_storages() {
137137
return info;
138138
}
139139
};
140-
static ipc::unordered_map<std::size_t, chunk_t> chunk_s;
140+
thread_local ipc::unordered_map<std::size_t, chunk_t> chunk_s;
141141
return chunk_s;
142142
}
143143

144144
chunk_info_t *chunk_storage_info(std::size_t chunk_size) {
145-
static std::mutex lock;
146-
IPC_UNUSED_ std::lock_guard<std::mutex> guard {lock};
147145
return chunk_storages()[chunk_size].get_info(chunk_size);
148146
}
149147

test/test_ipc.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ void test_sr(char const * name, int s_cnt, int r_cnt) {
128128
return;
129129
}
130130
ASSERT_TRUE((i >= 0) && (i < (int)data_set__.get().size()));
131-
if (data_set__.get()[i] != got) {
131+
auto const &data_set = data_set__.get()[i];
132+
if (data_set != got) {
132133
printf("data_set__.get()[%d] != got, size = %zd/%zd\n",
133-
i, data_set__.get()[i].size(), got.size());
134+
i, data_set.size(), got.size());
134135
EXPECT_TRUE(false);
135136
}
136137
}
@@ -169,7 +170,7 @@ TEST(IPC, 1vN) {
169170
//test_sr<relat::single, relat::multi , trans::unicast >("smu", 1, MultiMax);
170171
//test_sr<relat::multi , relat::multi , trans::unicast >("mmu", 1, MultiMax);
171172
test_sr<relat::single, relat::multi , trans::broadcast>("smb", 1, MultiMax);
172-
test_sr<relat::multi , relat::multi , trans::broadcast>("mmb", 1, MultiMax);
173+
//test_sr<relat::multi , relat::multi , trans::broadcast>("mmb", 1, MultiMax);
173174
}
174175

175176
TEST(IPC, Nv1) {

0 commit comments

Comments
 (0)