@@ -72,9 +72,7 @@ CacheAllocator<CacheTrait>::CacheAllocator(SharedMemNewT, Config config)
7272 AccessContainer::getRequiredSize (
7373 config_.accessConfig.getNumBuckets()),
7474 nullptr,
75- ShmSegmentOpts(config_.accessConfig.getPageSize(),
76- false,
77- config_.usePosixShm))
75+ ShmSegmentOpts(config_.accessConfig.getPageSize()))
7876 .addr,
7977 compressor_,
8078 [this](Item* it) -> WriteHandle { return acquire (it); })),
@@ -85,9 +83,7 @@ CacheAllocator<CacheTrait>::CacheAllocator(SharedMemNewT, Config config)
8583 AccessContainer::getRequiredSize (
8684 config_.chainedItemAccessConfig.getNumBuckets()),
8785 nullptr,
88- ShmSegmentOpts(config_.accessConfig.getPageSize(),
89- false,
90- config_.usePosixShm))
86+ ShmSegmentOpts(config_.accessConfig.getPageSize()))
9187 .addr,
9288 compressor_,
9389 [this](Item* it) -> WriteHandle { return acquire (it); })),
@@ -103,8 +99,7 @@ CacheAllocator<CacheTrait>::CacheAllocator(SharedMemNewT, Config config)
10399 config_.isNvmCacheEncryptionEnabled (),
104100 config_.isNvmCacheTruncateAllocSizeEnabled ()} {
105101 initCommon (false );
106- shmManager_->removeShm (detail::kShmInfoName ,
107- PosixSysVSegmentOpts (config_.usePosixShm ));
102+ shmManager_->removeShm (detail::kShmInfoName );
108103}
109104
110105template <typename CacheTrait>
@@ -122,19 +117,17 @@ CacheAllocator<CacheTrait>::CacheAllocator(SharedMemAttachT, Config config)
122117 accessContainer_(std::make_unique<AccessContainer>(
123118 deserializer_->deserialize<AccessSerializationType>(),
124119 config_.accessConfig,
125- shmManager_->attachShm(
126- detail::kShmHashTableName ,
127- nullptr ,
128- ShmSegmentOpts (PageSizeT::NORMAL, false , config_.usePosixShm)),
120+ shmManager_->attachShm(detail::kShmHashTableName ,
121+ nullptr ,
122+ ShmSegmentOpts (PageSizeT::NORMAL)),
129123 compressor_,
130124 [this](Item* it) -> WriteHandle { return acquire (it); })),
131125 chainedItemAccessContainer_(std::make_unique<AccessContainer>(
132126 deserializer_->deserialize<AccessSerializationType>(),
133127 config_.chainedItemAccessConfig,
134- shmManager_->attachShm(
135- detail::kShmChainedItemHashTableName ,
136- nullptr ,
137- ShmSegmentOpts (PageSizeT::NORMAL, false , config_.usePosixShm)),
128+ shmManager_->attachShm(detail::kShmChainedItemHashTableName ,
129+ nullptr ,
130+ ShmSegmentOpts (PageSizeT::NORMAL)),
138131 compressor_,
139132 [this](Item* it) -> WriteHandle { return acquire (it); })),
140133 chainedItemLocks_(config_.chainedItemsLockPower,
@@ -155,8 +148,7 @@ CacheAllocator<CacheTrait>::CacheAllocator(SharedMemAttachT, Config config)
155148 // We will create a new info shm segment on shutDown(). If we don't remove
156149 // this info shm segment here and the new info shm segment's size is larger
157150 // than this one, creating new one will fail.
158- shmManager_->removeShm (detail::kShmInfoName ,
159- PosixSysVSegmentOpts (config_.usePosixShm ));
151+ shmManager_->removeShm (detail::kShmInfoName );
160152}
161153
162154template <typename CacheTrait>
@@ -174,7 +166,11 @@ std::unique_ptr<MemoryAllocator>
174166CacheAllocator<CacheTrait>::createNewMemoryAllocator() {
175167 ShmSegmentOpts opts;
176168 opts.alignment = sizeof (Slab);
177- opts.typeOpts = PosixSysVSegmentOpts (config_.usePosixShm );
169+ if (config_.usePosixShm ) {
170+ opts.typeOpts = PosixShmSegmentOpts{};
171+ } else {
172+ opts.typeOpts = SysVShmSegmentOpts{};
173+ }
178174 return std::make_unique<MemoryAllocator>(
179175 getAllocatorConfig (config_),
180176 shmManager_
@@ -189,7 +185,11 @@ std::unique_ptr<MemoryAllocator>
189185CacheAllocator<CacheTrait>::restoreMemoryAllocator() {
190186 ShmSegmentOpts opts;
191187 opts.alignment = sizeof (Slab);
192- opts.typeOpts = PosixSysVSegmentOpts (config_.usePosixShm );
188+ if (config_.usePosixShm ) {
189+ opts.typeOpts = PosixShmSegmentOpts{};
190+ } else {
191+ opts.typeOpts = SysVShmSegmentOpts{};
192+ }
193193 return std::make_unique<MemoryAllocator>(
194194 deserializer_->deserialize <MemoryAllocator::SerializationType>(),
195195 shmManager_
@@ -298,8 +298,7 @@ void CacheAllocator<CacheTrait>::initWorkers() {
298298template <typename CacheTrait>
299299std::unique_ptr<Deserializer> CacheAllocator<CacheTrait>::createDeserializer() {
300300 auto infoAddr = shmManager_->attachShm (
301- detail::kShmInfoName , nullptr ,
302- ShmSegmentOpts (PageSizeT::NORMAL, false , config_.usePosixShm ));
301+ detail::kShmInfoName , nullptr , ShmSegmentOpts (PageSizeT::NORMAL, false ));
303302 return std::make_unique<Deserializer>(
304303 reinterpret_cast <uint8_t *>(infoAddr.addr ),
305304 reinterpret_cast <uint8_t *>(infoAddr.addr ) + infoAddr.size );
@@ -3162,7 +3161,11 @@ void CacheAllocator<CacheTrait>::saveRamCache() {
31623161 ioBuf->coalesce ();
31633162
31643163 ShmSegmentOpts opts;
3165- opts.typeOpts = PosixSysVSegmentOpts (config_.usePosixShm );
3164+ if (config_.usePosixShm ) {
3165+ opts.typeOpts = PosixShmSegmentOpts{};
3166+ } else {
3167+ opts.typeOpts = SysVShmSegmentOpts{};
3168+ }
31663169
31673170 void * infoAddr =
31683171 shmManager_
@@ -3537,11 +3540,25 @@ bool CacheAllocator<
35373540 // cache dir did not exist. Try to nuke the segments we know by name.
35383541 // Any other concurrent process can not be attached to the segments or
35393542 // even if it does, we want to mark it for destruction.
3540- ShmManager::removeByName (cacheDir, detail::kShmInfoName , posix);
3541- ShmManager::removeByName (cacheDir, detail::kShmCacheName , posix);
3542- ShmManager::removeByName (cacheDir, detail::kShmHashTableName , posix);
3543- ShmManager::removeByName (cacheDir, detail::kShmChainedItemHashTableName ,
3544- posix);
3543+ if (posix) {
3544+ ShmManager::removeByName (cacheDir, detail::kShmInfoName ,
3545+ PosixShmSegmentOpts{});
3546+ ShmManager::removeByName (cacheDir, detail::kShmCacheName ,
3547+ PosixShmSegmentOpts{});
3548+ ShmManager::removeByName (cacheDir, detail::kShmHashTableName ,
3549+ PosixShmSegmentOpts{});
3550+ ShmManager::removeByName (cacheDir, detail::kShmChainedItemHashTableName ,
3551+ PosixShmSegmentOpts{});
3552+ } else { // SysV
3553+ ShmManager::removeByName (cacheDir, detail::kShmInfoName ,
3554+ SysVShmSegmentOpts{});
3555+ ShmManager::removeByName (cacheDir, detail::kShmCacheName ,
3556+ SysVShmSegmentOpts{});
3557+ ShmManager::removeByName (cacheDir, detail::kShmHashTableName ,
3558+ SysVShmSegmentOpts{});
3559+ ShmManager::removeByName (cacheDir, detail::kShmChainedItemHashTableName ,
3560+ SysVShmSegmentOpts{});
3561+ }
35453562
35463563 // TODO(SHM_FILE): try to nuke segments of differente types (which require
35473564 // extra info)
0 commit comments