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

Method cache_writer

src/jrd/cch.cpp:3018–3156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3016
3017
3018void BufferControl::cache_writer(BufferControl* bcb)
3019{
3020/**************************************
3021 *
3022 * c a c h e _ w r i t e r
3023 *
3024 **************************************
3025 *
3026 * Functional description
3027 * Write dirty pages to database to maintain an adequate supply of free pages.
3028 *
3029 **************************************/
3030 FbLocalStatus status_vector;
3031 Database* const dbb = bcb->bcb_database;
3032
3033 try
3034 {
3035 UserId user;
3036 user.setUserName("Cache Writer");
3037
3038 Jrd::Attachment* const attachment = Jrd::Attachment::create(dbb, nullptr);
3039 RefPtr<SysStableAttachment> sAtt(FB_NEW SysStableAttachment(attachment));
3040 attachment->setStable(sAtt);
3041 attachment->att_filename = dbb->dbb_filename;
3042 attachment->att_user = &user;
3043
3044 BackgroundContextHolder tdbb(dbb, attachment, &status_vector, FB_FUNCTION);
3045 Jrd::Attachment::UseCountHolder use(attachment);
3046
3047 try
3048 {
3049 LCK_init(tdbb, LCK_OWNER_attachment);
3050 PAG_header(tdbb, true);
3051 PAG_attachment_id(tdbb);
3052 TRA_init(attachment);
3053
3054 Monitoring::publishAttachment(tdbb);
3055
3056 sAtt->initDone();
3057
3058 bcb->bcb_flags |= BCB_cache_writer;
3059 bcb->bcb_flags &= ~BCB_writer_start;
3060
3061 // Notify our creator that we have started
3062 bcb->bcb_writer_init.release();
3063
3064 while (bcb->bcb_flags & BCB_cache_writer)
3065 {
3066 bcb->bcb_flags |= BCB_writer_active;
3067#ifdef CACHE_READER
3068 SLONG starting_page = -1;
3069#endif
3070
3071 if (dbb->dbb_flags & DBB_suspend_bgio)
3072 {
3073 EngineCheckout cout(tdbb, FB_FUNCTION);
3074 bcb->bcb_writer_sem.tryEnter(10);
3075 continue;

Callers

nothing calls this directly

Calls 15

createFunction · 0.85
LCK_initFunction · 0.85
PAG_headerFunction · 0.85
PAG_attachment_idFunction · 0.85
TRA_initFunction · 0.85
get_dirty_bufferFunction · 0.85
write_bufferFunction · 0.85
JRD_rescheduleFunction · 0.85
prefetch_initFunction · 0.85
prefetch_prologueFunction · 0.85
prefetch_ioFunction · 0.85
prefetch_epilogueFunction · 0.85

Tested by

no test coverage detected