MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / makeSharedMemory

Function makeSharedMemory

src/storage/shared_memory.cpp:197–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195#endif
196
197std::unique_ptr<SharedMemory> makeSharedMemory(const ProjID proj_id, const uint64_t size)
198{
199 OSRMLockFile lock_file(proj_id);
200 try
201 {
202 if (!std::filesystem::exists(lock_file.to_path()))
203 {
204 if (size == 0)
205 {
206 throw util::exception("Lock file does not exist, exiting. " + SOURCE_REF);
207 }
208 else
209 {
210 std::ofstream ofs(lock_file.to_path());
211 }
212 }
213 return std::make_unique<SharedMemory>(proj_id, size);
214 }
215 catch (const interprocess_exception &e)
216 {
217 util::Log(logERROR) << "Error while attempting to allocate shared memory: " << e.what()
218 << ", code: " << e.get_error_code()
219 << ", lock file: " << lock_file.to_path();
220 throw util::exception(e.what() + SOURCE_REF);
221 }
222}
223
224// Try to use a directory for lock files. Creates it if needed.
225// Returns true on success, false if the directory cannot be used.

Callers 5

listRegionsFunction · 0.85
setupRegionFunction · 0.85
swapDataFunction · 0.85
RunMethod · 0.85
SharedMemoryAllocatorMethod · 0.85

Calls 4

exceptionClass · 0.85
LogClass · 0.85
to_pathMethod · 0.80
whatMethod · 0.80

Tested by

no test coverage detected