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

Function SDW_check

src/jrd/sdw.cpp:269–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267
268
269void SDW_check(thread_db* tdbb)
270{
271/**************************************
272 *
273 * S D W _ c h e c k
274 *
275 **************************************
276 *
277 * Functional description
278 * Check a shadow to see if it needs to
279 * be deleted or shut down.
280 *
281 **************************************/
282 SET_TDBB(tdbb);
283 Database* dbb = tdbb->getDatabase();
284
285 SyncLockGuard guard(&dbb->dbb_shadow_sync, SYNC_EXCLUSIVE, "SDW_check");
286
287 // first get rid of any shadows that need to be
288 // deleted or shutdown; deleted shadows must also be shutdown
289
290 // Check to see if there is a valid shadow in the shadow set,
291 // if not then it is time to start an conditional shadow (if one has been defined).
292
293 Shadow* next_shadow;
294 for (Shadow* shadow = dbb->dbb_shadow; shadow; shadow = next_shadow)
295 {
296 next_shadow = shadow->sdw_next;
297
298 if (shadow->sdw_flags & SDW_delete)
299 {
300 MET_delete_shadow(tdbb, shadow->sdw_number);
301 gds__log("shadow %s deleted from database %s due to unavailability on write",
302 shadow->sdw_file->fil_string, dbb->dbb_filename.c_str());
303 }
304
305 // note that shutting down a shadow is destructive to the shadow block
306
307 if (shadow->sdw_flags & SDW_shutdown)
308 shutdown_shadow(shadow);
309 }
310
311 if (SDW_check_conditional(tdbb))
312 {
313 if (SDW_lck_update(tdbb, 0))
314 {
315 Lock temp_lock(tdbb, sizeof(SLONG), LCK_update_shadow);
316 Lock* lock = &temp_lock;
317 lock->setKey(-1);
318
319 LCK_lock(tdbb, lock, LCK_EX, LCK_NO_WAIT);
320 if (lock->lck_physical == LCK_EX)
321 {
322 SDW_notify(tdbb);
323 SDW_dump_pages(tdbb);
324 LCK_release(tdbb, lock);
325 }
326 }

Callers 1

CCH_flushFunction · 0.85

Calls 11

SET_TDBBFunction · 0.85
shutdown_shadowFunction · 0.85
SDW_check_conditionalFunction · 0.85
SDW_lck_updateFunction · 0.85
LCK_lockFunction · 0.85
SDW_notifyFunction · 0.85
SDW_dump_pagesFunction · 0.85
LCK_releaseFunction · 0.85
getDatabaseMethod · 0.80
c_strMethod · 0.45
setKeyMethod · 0.45

Tested by

no test coverage detected