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

Method acquire_shmem

src/lock/lock.cpp:1046–1193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1044
1045
1046void LockManager::acquire_shmem(SRQ_PTR owner_offset)
1047{
1048/**************************************
1049 *
1050 * a c q u i r e
1051 *
1052 **************************************
1053 *
1054 * Functional description
1055 * Acquire the lock file. If it's busy, wait for it.
1056 *
1057 **************************************/
1058 LocalStatus ls;
1059 CheckStatusWrapper localStatus(&ls);
1060
1061 // Perform a spin wait on the lock table mutex. This should only
1062 // be used on SMP machines; it doesn't make much sense otherwise.
1063
1064 const ULONG spins_to_try = m_acquireSpins ? m_acquireSpins : 1;
1065 bool locked = false;
1066 ULONG spins = 0;
1067 while (spins++ < spins_to_try)
1068 {
1069 if (m_sharedMemory->mutexLockCond())
1070 {
1071 locked = true;
1072 break;
1073 }
1074
1075 m_blockage = true;
1076 }
1077
1078 // If the spin wait didn't succeed then wait forever
1079
1080 if (!locked)
1081 m_sharedMemory->mutexLock();
1082
1083 // Reattach if someone has just deleted the shared file
1084
1085 while (m_sharedMemory->getHeader()->isDeleted())
1086 {
1087 fb_assert(!m_process);
1088 if (m_process)
1089 bug(NULL, "Process disappeared in LockManager::acquire_shmem");
1090
1091 // Shared memory must be empty at this point
1092 fb_assert(SRQ_EMPTY(m_sharedMemory->getHeader()->lhb_processes));
1093
1094 // no sense thinking about statistics now
1095 m_blockage = false;
1096
1097 m_sharedMemory->mutexUnlock();
1098 m_sharedMemory.reset();
1099
1100 Thread::yield();
1101
1102 if (!init_shared_file(&localStatus))
1103 bug(NULL, "ISC_map_file failed (reattach shared file)");

Callers 2

LockTableGuardMethod · 0.80
LockTableCheckoutMethod · 0.80

Calls 10

getThreadIdFunction · 0.85
getTotalMappedFunction · 0.85
mutexLockCondMethod · 0.80
mutexLockMethod · 0.80
isDeletedMethod · 0.80
mutexUnlockMethod · 0.80
remapFileMethod · 0.80
yieldClass · 0.50
getHeaderMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected