| 278 | |
| 279 | public: |
| 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 | { |
no test coverage detected