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

Method linkSelf

src/jrd/replication/ChangeLog.cpp:480–528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

478}
479
480void ChangeLog::linkSelf()
481{
482 static const auto process_id = getpid();
483
484 const auto state = m_sharedMemory->getHeader();
485
486 fb_assert(state->pidLower <= PID_CAPACITY);
487 fb_assert(state->pidUpper <= PID_CAPACITY);
488
489 fb_assert(state->pidLower <= state->pidUpper);
490
491 if (state->pidLower == state->pidUpper)
492 {
493 if (state->pidUpper == PID_CAPACITY)
494 {
495 for (ULONG i = 0; i < state->pidUpper; i++)
496 {
497 fb_assert(state->pids[i]);
498
499 if (!state->pids[i] || // being a bit paranoid doesn't hurt
500 state->pids[i] == process_id ||
501 !ISC_check_process_existence(state->pids[i]))
502 {
503 state->pids[i] = process_id;
504 return;
505 }
506 }
507
508 status_exception::raise(Arg::Gds(isc_imp_exc));
509 }
510
511 state->pids[state->pidUpper++] = process_id;
512 state->pidLower = state->pidUpper;
513 }
514 else
515 {
516 if (state->pidLower == PID_CAPACITY) // safety check
517 status_exception::raise(Arg::Gds(isc_imp_exc));
518
519 fb_assert(!state->pids[state->pidLower]);
520 state->pids[state->pidLower] = process_id;
521
522 while (++state->pidLower < state->pidUpper)
523 {
524 if (!state->pids[state->pidLower])
525 break;
526 }
527 }
528}
529
530bool ChangeLog::unlinkSelf()
531{

Callers

nothing calls this directly

Calls 4

raiseFunction · 0.85
GdsClass · 0.85
getHeaderMethod · 0.45

Tested by

no test coverage detected