Skip to content

Commit e3c8f8e

Browse files
committed
adjust test, chunk_storages revert to static
1 parent 3490945 commit e3c8f8e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/ipc.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,13 @@ auto& chunk_storages() {
137137
return info;
138138
}
139139
};
140-
thread_local ipc::unordered_map<std::size_t, chunk_t> chunk_s;
140+
static 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};
145147
return chunk_storages()[chunk_size].get_info(chunk_size);
146148
}
147149

test/test_ipc.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ void test_basic(char const * name) {
7575
EXPECT_FALSE(que1.try_send(test2));
7676

7777
que_t que2 { que1.name(), ipc::receiver };
78-
EXPECT_TRUE(que1.send(test1));
79-
EXPECT_TRUE(que1.try_send(test2));
78+
ASSERT_TRUE(que1.send(test1));
79+
ASSERT_TRUE(que1.try_send(test2));
8080

8181
EXPECT_EQ(que2.recv(), test1);
8282
EXPECT_EQ(que2.recv(), test2);
@@ -128,7 +128,11 @@ 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-
EXPECT_EQ(data_set__.get()[i], got);
131+
if (data_set__.get()[i] != got) {
132+
printf("data_set__.get()[%d] != got, size = %zd/%zd\n",
133+
i, data_set__.get()[i].size(), got.size());
134+
EXPECT_TRUE(false);
135+
}
132136
}
133137
};
134138
}

0 commit comments

Comments
 (0)