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

Method SharedMemoryBase

src/common/isc_sync.cpp:1610–1958  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1608
1609
1610SharedMemoryBase::SharedMemoryBase(const TEXT* filename, ULONG length, IpcObject* cb, bool /*skipLock*/)
1611 : sh_mem_mutex(0), sh_mem_length_mapped(0), sh_mem_increment(0),
1612 sh_mem_handle(INVALID_HANDLE_VALUE), sh_mem_object(0), sh_mem_interest(0), sh_mem_hdr_object(0),
1613 sh_mem_hdr_address(0), sh_mem_header(NULL), sh_mem_callback(cb), sh_mem_unlink(false)
1614{
1615/**************************************
1616 *
1617 * c t o r ( W I N _ N T )
1618 *
1619 **************************************
1620 *
1621 * Functional description
1622 * Try to map a given file. If we are the first (i.e. only)
1623 * process to map the file, call a given initialization
1624 * routine (if given) or punt (leaving the file unmapped).
1625 *
1626 **************************************/
1627 fb_assert(sh_mem_callback);
1628 sh_mem_name[0] = '\0';
1629
1630 HANDLE event_handle = 0;
1631 int retry_count = 0;
1632
1633 TEXT expanded_filename[MAXPATHLEN];
1634 iscPrefixLock(expanded_filename, filename, true);
1635
1636 bool init_flag = false;
1637 DWORD err = 0;
1638
1639 if (length)
1640 {
1641 LocalStatus ls;
1642 CheckStatusWrapper statusVector(&ls);
1643
1644 sh_mem_increment = length = FB_ALIGN(length, getSystemPageSize(&statusVector));
1645
1646 if (statusVector.hasData())
1647 status_exception::raise(&statusVector);
1648 }
1649
1650 // retry to attach to mmapped file if the process initializing dies during initialization.
1651
1652 retry:
1653 if (retry_count++ > 0)
1654 Thread::sleep(10);
1655
1656 // Create an event that can be used to determine if someone has already
1657 // initialized shared memory.
1658
1659 TEXT object_name[MAXPATHLEN];
1660 if (!make_object_name(object_name, sizeof(object_name), filename, "_event"))
1661 {
1662 system_call_failed::raise("make_object_name");
1663 }
1664
1665 if (!init_flag)
1666 {
1667 event_handle = CreateEvent(ISC_get_security_desc(), TRUE, FALSE, object_name);

Callers

nothing calls this directly

Calls 14

iscPrefixLockFunction · 0.85
FB_ALIGNFunction · 0.85
raiseFunction · 0.85
make_object_nameFunction · 0.85
ISC_get_security_descFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
ISC_mutex_initFunction · 0.85
getMappedFileNameFunction · 0.70
sleepFunction · 0.50
hasDataMethod · 0.45
raiseMethod · 0.45

Tested by

no test coverage detected