size of shm needs to be only sometimes checked when opening shared memory (#443)

This commit is contained in:
Dhanya Thattil
2022-05-16 12:27:48 +02:00
committed by GitHub
parent 88649a00b6
commit 8d6b8d66cc
6 changed files with 14 additions and 13 deletions

View File

@ -101,14 +101,15 @@ template <typename T> class SharedMemory {
LOG(logINFO) << "Shared memory created " << name;
}
void openSharedMemory() {
void openSharedMemory(bool verifySize) {
int fd = shm_open(name.c_str(), O_RDWR, 0);
if (fd < 0) {
std::string msg = "Open existing shared memory " + name +
" failed: " + strerror(errno);
throw SharedMemoryError(msg);
}
checkSize(fd);
if (verifySize)
checkSize(fd);
shared_struct = mapSharedMemory(fd);
}