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

Method remapFile

src/common/isc_sync.cpp:2516–2571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2514#ifdef HAVE_MMAP
2515#define ISC_REMAP_FILE_DEFINED
2516bool SharedMemoryBase::remapFile(CheckStatusWrapper* statusVector, ULONG new_length, bool flag)
2517{
2518/**************************************
2519 *
2520 * I S C _ r e m a p _ f i l e ( U N I X - m m a p )
2521 *
2522 **************************************
2523 *
2524 * Functional description
2525 * Try to re-map a given file.
2526 *
2527 **************************************/
2528 if (!new_length)
2529 {
2530 error(statusVector, "Zero new_length is requested", 0);
2531 return false;
2532 }
2533
2534 if (flag)
2535 {
2536 new_length = FB_ALIGN(new_length, getSystemPageSize(statusVector));
2537
2538 FB_UNUSED(os_utils::ftruncate(mainLock->getFd(), new_length));
2539
2540 if (new_length > sh_mem_length_mapped)
2541 {
2542 if (!allocFileSpace(mainLock->getFd(), sh_mem_length_mapped,
2543 new_length - sh_mem_length_mapped, statusVector))
2544 {
2545 return false;
2546 }
2547 }
2548 }
2549
2550 MemoryHeader* const address = (MemoryHeader*) os_utils::mmap(0, new_length,
2551 PROT_READ | PROT_WRITE, MAP_SHARED, mainLock->getFd(), 0);
2552
2553 if ((U_IPTR) address == (U_IPTR) -1)
2554 {
2555 error(statusVector, "mmap() failed", errno);
2556 return false;
2557 }
2558
2559 munmap(sh_mem_header, sh_mem_length_mapped);
2560
2561 IPC_TRACE(("ISC_remap_file %p to %p %d\n", sh_mem_header, address, new_length));
2562
2563 sh_mem_header = (MemoryHeader*) address;
2564 sh_mem_length_mapped = new_length;
2565
2566#if defined(HAVE_SHARED_MUTEX_SECTION) && !defined(USE_MUTEX_MAP)
2567 sh_mem_mutex = &sh_mem_header->mhb_mutex;
2568#endif
2569
2570 return address;
2571}
2572#endif // HAVE_MMAP
2573#endif // UNIX

Callers 13

acquire_shmemMethod · 0.80
allocMethod · 0.80
CLIB_ROUTINE mainFunction · 0.80
allocateSnapshotSlotMethod · 0.80
remapSnapshotsMethod · 0.80
acquireMethod · 0.80
ensureSpaceMethod · 0.80
event.cppFile · 0.80
alloc_globalMethod · 0.80
acquireMethod · 0.80
allocSlotMethod · 0.80
extendMethod · 0.80

Calls 10

FB_ALIGNFunction · 0.85
ftruncateFunction · 0.85
allocFileSpaceFunction · 0.85
mmapFunction · 0.85
make_object_nameFunction · 0.85
ISC_get_security_descFunction · 0.85
GdsClass · 0.85
getFdMethod · 0.80
errorFunction · 0.70
copyToMethod · 0.45

Tested by

no test coverage detected