| 1631 | |
| 1632 | |
| 1633 | void CCH_init2(thread_db* tdbb) |
| 1634 | { |
| 1635 | Database* dbb = tdbb->getDatabase(); |
| 1636 | BufferControl* bcb = dbb->dbb_bcb; |
| 1637 | |
| 1638 | // Avoid running CCH_init2() in 2 parallel threads |
| 1639 | Firebird::MutexEnsureUnlock guard(bcb->bcb_threadStartup, FB_FUNCTION); |
| 1640 | guard.enter(); |
| 1641 | |
| 1642 | if (!(bcb->bcb_flags & BCB_exclusive) || (bcb->bcb_flags & (BCB_cache_writer | BCB_writer_start))) |
| 1643 | return; |
| 1644 | |
| 1645 | #ifdef CACHE_READER |
| 1646 | if (gds__thread_start(cache_reader, dbb, THREAD_high, 0, 0)) |
| 1647 | { |
| 1648 | ERR_bugcheck_msg("cannot start thread"); |
| 1649 | } |
| 1650 | |
| 1651 | { // scope |
| 1652 | Database::Checkout dcoHolder(dbb, FB_FUNCTION); |
| 1653 | dbb->dbb_reader_init.enter(); |
| 1654 | } |
| 1655 | #endif |
| 1656 | |
| 1657 | const Attachment* att = tdbb->getAttachment(); |
| 1658 | if (!(dbb->dbb_flags & DBB_read_only) && !(att->att_flags & ATT_security_db)) |
| 1659 | { |
| 1660 | // writer startup in progress |
| 1661 | bcb->bcb_flags |= BCB_writer_start; |
| 1662 | guard.leave(); |
| 1663 | |
| 1664 | try |
| 1665 | { |
| 1666 | bcb->bcb_writer_fini.run(bcb); |
| 1667 | } |
| 1668 | catch (const Exception&) |
| 1669 | { |
| 1670 | bcb->bcb_flags &= ~BCB_writer_start; |
| 1671 | ERR_bugcheck_msg("cannot start cache writer thread"); |
| 1672 | } |
| 1673 | |
| 1674 | bcb->bcb_writer_init.enter(); |
| 1675 | } |
| 1676 | } |
| 1677 | |
| 1678 | |
| 1679 | void CCH_mark(thread_db* tdbb, WIN* window, bool mark_system, bool must_write) |
no test coverage detected