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

Method initializeTpc

src/jrd/tpc.cpp:228–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228void TipCache::initializeTpc(thread_db *tdbb)
229{
230 Database* dbb = tdbb->getDatabase();
231
232 // Initialization can only be called on a TipCache that is not initialized
233 fb_assert(!m_transactionsPerBlock);
234
235 m_lock = FB_NEW_RPT(*dbb->dbb_permanent, 0) Lock(tdbb, 0, LCK_tpc_init);
236
237 // wait for finalizers (SW) locks
238 if (!LCK_lock(tdbb, m_lock, LCK_PR, LCK_WAIT))
239 ERR_bugcheck_msg("Unable to obtain TPC lock (PR)");
240
241 string fileName;
242 fileName.printf(TPC_HDR_FILE, dbb->getUniqueFileId().c_str());
243
244 try
245 {
246 m_tpcHeader = FB_NEW_POOL(*dbb->dbb_permanent) SharedMemory<GlobalTpcHeader>(
247 fileName.c_str(), sizeof(GlobalTpcHeader), &globalTpcInitializer);
248
249 const auto* header = m_tpcHeader->getHeader();
250 globalTpcInitializer.checkHeader(header);
251 }
252 catch (const Exception& ex)
253 {
254 iscLogException("TPC: Cannot initialize the shared memory region (header)", ex);
255
256 LCK_convert(tdbb, m_lock, LCK_SR, LCK_WAIT); // never fails
257 finalizeTpc(tdbb);
258 throw;
259 }
260
261 try
262 {
263 fileName.printf(SNAPSHOTS_FILE, dbb->getUniqueFileId().c_str());
264 m_snapshots = FB_NEW_POOL(*dbb->dbb_permanent) SharedMemory<SnapshotList>(
265 fileName.c_str(), dbb->dbb_config->getSnapshotsMemSize(), &snapshotsInitializer);
266
267 const auto* header = m_snapshots->getHeader();
268 snapshotsInitializer.checkHeader(header);
269 }
270 catch (const Exception& ex)
271 {
272 iscLogException("TPC: Cannot initialize the shared memory region (snapshots)", ex);
273
274 LCK_convert(tdbb, m_lock, LCK_SR, LCK_WAIT); // never fails
275 finalizeTpc(tdbb);
276 throw;
277 }
278
279 fb_assert(m_snapshots->getHeader()->mhb_version == TPC_VERSION);
280
281 LCK_convert(tdbb, m_lock, LCK_SR, LCK_WAIT); // never fails
282}
283
284void TipCache::initTransactionsPerBlock(ULONG blockSize)
285{

Callers 1

startTipCacheMethod · 0.80

Calls 10

LCK_lockFunction · 0.85
ERR_bugcheck_msgFunction · 0.85
iscLogExceptionFunction · 0.85
LCK_convertFunction · 0.85
getDatabaseMethod · 0.80
LockClass · 0.70
printfMethod · 0.45
c_strMethod · 0.45
getHeaderMethod · 0.45
checkHeaderMethod · 0.45

Tested by

no test coverage detected