| 4712 | |
| 4713 | |
| 4714 | static int write_buffer(thread_db* tdbb, |
| 4715 | BufferDesc* bdb, |
| 4716 | const PageNumber page, |
| 4717 | const bool write_thru, |
| 4718 | FbStatusVector* const status, const bool write_this_page) |
| 4719 | { |
| 4720 | /************************************** |
| 4721 | * |
| 4722 | * w r i t e _ b u f f e r |
| 4723 | * |
| 4724 | ************************************** |
| 4725 | * |
| 4726 | * Functional description |
| 4727 | * Write a dirty buffer. This may recurse due to |
| 4728 | * precedence problems. |
| 4729 | * |
| 4730 | * input: write_this_page |
| 4731 | * = true if the input page needs to be written |
| 4732 | * before returning. (normal case) |
| 4733 | * = false if the input page is being written |
| 4734 | * because of precedence. Only write |
| 4735 | * one page and return so that the caller |
| 4736 | * can re-establish the need to write this |
| 4737 | * page. |
| 4738 | * |
| 4739 | * return: 0 = Write failed. |
| 4740 | * 1 = Page is written. Page was written by this |
| 4741 | * call, or was written by someone else, or the |
| 4742 | * cache buffer is already reassigned. |
| 4743 | * 2 = Only possible if write_this_page is false. |
| 4744 | * This input page is not written. One |
| 4745 | * page higher in precedence is written |
| 4746 | * though. Probable action: re-establich the |
| 4747 | * need to write this page and retry write. |
| 4748 | * |
| 4749 | **************************************/ |
| 4750 | SET_TDBB(tdbb); |
| 4751 | #ifdef SUPERSERVER_V2 |
| 4752 | Database* const dbb = tdbb->getDatabase(); |
| 4753 | #endif |
| 4754 | |
| 4755 | bdb->lockIO(tdbb); |
| 4756 | if (bdb->bdb_page != page) |
| 4757 | { |
| 4758 | bdb->unLockIO(tdbb); |
| 4759 | return 1; |
| 4760 | } |
| 4761 | |
| 4762 | if ((bdb->bdb_flags & BDB_marked) && !(bdb->bdb_flags & BDB_faked)) |
| 4763 | BUGCHECK(217); // msg 217 buffer marked for update |
| 4764 | |
| 4765 | if (!(bdb->bdb_flags & BDB_dirty) && !(write_thru && bdb->bdb_flags & BDB_db_dirty)) |
| 4766 | { |
| 4767 | bdb->unLockIO(tdbb); |
| 4768 | clear_precedence(tdbb, bdb); |
| 4769 | return 1; |
| 4770 | } |
| 4771 |
no test coverage detected