MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / get

Function get

src/common/isc_sync.cpp:280–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278
279public:
280 static SharedFileInfo* get(const char* fileName)
281 {
282 DevNode id(getNode(fileName));
283
284 MutexLockGuard g(sharedFilesMutex, FB_FUNCTION);
285
286 SharedFileInfo* file = nullptr;
287 if (id.f_ino)
288 {
289 SharedFileInfo** got = sharedFiles->get(id);
290 if (got)
291 {
292 file = *got;
293 DEB_FLOCK("'%s': in map %p\n", fileName, file);
294 file->assertNonZero();
295 }
296 }
297
298 if (!file)
299 {
300 int fd = os_utils::openCreateSharedFile(fileName, 0);
301 id = getNode(fd);
302 file = FB_NEW_POOL(*getDefaultMemoryPool()) SharedFileInfo(fd, id);
303 SharedFileInfo** put = sharedFiles->put(id);
304 fb_assert(put);
305 *put = file;
306 DEB_FLOCK("'%s': new %p\n", fileName, file);
307 }
308
309 file->addRef();
310 return file;
311 }
312
313 int release() const override
314 {

Callers 3

FileLockMethod · 0.70
getOrPutMethod · 0.50
GenericMapClass · 0.50

Calls 9

getNodeFunction · 0.85
DEB_FLOCKFunction · 0.85
getDefaultMemoryPoolFunction · 0.85
assertNonZeroMethod · 0.80
SharedFileInfoFunction · 0.70
openCreateSharedFileFunction · 0.50
getMethod · 0.45
putMethod · 0.45
addRefMethod · 0.45

Tested by

no test coverage detected