| 2208 | |
| 2209 | |
| 2210 | void CCH_shutdown(thread_db* tdbb) |
| 2211 | { |
| 2212 | /************************************** |
| 2213 | * |
| 2214 | * C C H _ s h u t d o w n |
| 2215 | * |
| 2216 | ************************************** |
| 2217 | * |
| 2218 | * Functional description |
| 2219 | * Shutdown database physical page locks. |
| 2220 | * |
| 2221 | **************************************/ |
| 2222 | Database* const dbb = tdbb->getDatabase(); |
| 2223 | BufferControl* const bcb = dbb->dbb_bcb; |
| 2224 | |
| 2225 | if (!bcb) |
| 2226 | return; |
| 2227 | |
| 2228 | #ifdef CACHE_READER |
| 2229 | // Shutdown the dedicated cache reader for this database |
| 2230 | |
| 2231 | if (bcb->bcb_flags & BCB_cache_reader) |
| 2232 | { |
| 2233 | bcb->bcb_flags &= ~BCB_cache_reader; |
| 2234 | dbb->dbb_reader_sem.release(); |
| 2235 | dbb->dbb_reader_fini.enter(); |
| 2236 | } |
| 2237 | #endif |
| 2238 | |
| 2239 | // Wait for cache writer startup to complete |
| 2240 | |
| 2241 | while (bcb->bcb_flags & BCB_writer_start) |
| 2242 | Thread::yield(); |
| 2243 | |
| 2244 | // Shutdown the dedicated cache writer for this database |
| 2245 | |
| 2246 | if (bcb->bcb_flags & BCB_cache_writer) |
| 2247 | { |
| 2248 | bcb->bcb_flags &= ~BCB_cache_writer; |
| 2249 | bcb->bcb_writer_sem.release(); // Wake up running thread |
| 2250 | bcb->bcb_writer_fini.waitForCompletion(); |
| 2251 | } |
| 2252 | |
| 2253 | SyncLockGuard bcbSync(&bcb->bcb_syncObject, SYNC_EXCLUSIVE, FB_FUNCTION); |
| 2254 | |
| 2255 | // Flush and release page buffers |
| 2256 | |
| 2257 | if (bcb->bcb_count) |
| 2258 | { |
| 2259 | try |
| 2260 | { |
| 2261 | if (dbb->dbb_flags & DBB_bugcheck) |
| 2262 | LongJump::raise(); |
| 2263 | |
| 2264 | CCH_flush(tdbb, FLUSH_FINI, 0); |
| 2265 | } |
| 2266 | catch (const Exception&) |
| 2267 | { |
no test coverage detected