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

Function SDW_check_conditional

src/jrd/sdw.cpp:331–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

329
330
331bool SDW_check_conditional(thread_db* tdbb)
332{
333/**************************************
334 *
335 * S D W _ c h e c k _ c o n d i t i o n a l
336 *
337 **************************************
338 *
339 * Functional description
340 * Check if a conditional shadow exists
341 * if so update meta data and return true
342 *
343 **************************************/
344 SET_TDBB(tdbb);
345 Database* dbb = tdbb->getDatabase();
346 CHECK_DBB(dbb);
347
348 SyncLockGuard guard(&dbb->dbb_shadow_sync, SYNC_EXCLUSIVE, "SDW_check_conditional");
349
350 // first get rid of any shadows that need to be
351 // deleted or shutdown; deleted shadows must also be shutdown
352
353 // Check to see if there is a valid shadow in the shadow set,
354 // if not then it is time to start an conditional shadow (if one has been defined).
355
356 bool start_conditional = true;
357 Shadow* next_shadow;
358 for (Shadow* shadow = dbb->dbb_shadow; shadow; shadow = next_shadow)
359 {
360 next_shadow = shadow->sdw_next;
361
362 if (!(shadow->sdw_flags & (SDW_delete | SDW_shutdown)))
363 if (!(shadow->sdw_flags & SDW_INVALID))
364 {
365 start_conditional = false;
366 break;
367 }
368 }
369
370 // if there weren't any conventional shadows, now is
371 // the time to start the first conditional shadow in the list
372 // Note that allocate_shadow keeps the sdw_next list sorted
373
374 if (start_conditional)
375 {
376 for (Shadow* shadow = dbb->dbb_shadow; shadow; shadow = shadow->sdw_next)
377 {
378 if ((shadow->sdw_flags & SDW_conditional) &&
379 !(shadow->sdw_flags & (SDW_IGNORE | SDW_rollover)))
380 {
381 shadow->sdw_flags &= ~SDW_conditional;
382
383 gds__log("conditional shadow %d %s activated for database %s",
384 shadow->sdw_number, shadow->sdw_file->fil_string, dbb->dbb_filename.c_str());
385 USHORT file_flags = FILE_shadow;
386 if (shadow->sdw_flags & SDW_manual)
387 file_flags |= FILE_manual;
388 MET_update_shadow(tdbb, shadow, file_flags);

Callers 3

CCH_write_all_shadowsFunction · 0.85
SDW_checkFunction · 0.85
SDW_rollover_to_shadowFunction · 0.85

Calls 4

SET_TDBBFunction · 0.85
CHECK_DBBFunction · 0.85
getDatabaseMethod · 0.80
c_strMethod · 0.45

Tested by

no test coverage detected