| 2550 | } |
| 2551 | |
| 2552 | void PageManager::initTempPageSpace(thread_db* tdbb) |
| 2553 | { |
| 2554 | SET_TDBB(tdbb); |
| 2555 | Database* const dbb = tdbb->getDatabase(); |
| 2556 | |
| 2557 | fb_assert(tempPageSpaceID == 0); |
| 2558 | |
| 2559 | if (dbb->dbb_config->getServerMode() != MODE_SUPER) |
| 2560 | { |
| 2561 | Jrd::Attachment* const attachment = tdbb->getAttachment(); |
| 2562 | |
| 2563 | if (!attachment->att_temp_pg_lock) |
| 2564 | { |
| 2565 | Lock* const lock = FB_NEW_RPT(*attachment->att_pool, 0) |
| 2566 | Lock(tdbb, sizeof(SLONG), LCK_page_space); |
| 2567 | |
| 2568 | while (true) |
| 2569 | { |
| 2570 | const double tmp = rand() * (MAX_USHORT - TEMP_PAGE_SPACE - 1.0) / (RAND_MAX + 1.0); |
| 2571 | lock->setKey(static_cast<SLONG>(tmp) + TEMP_PAGE_SPACE + 1); |
| 2572 | if (LCK_lock(tdbb, lock, LCK_write, LCK_NO_WAIT)) |
| 2573 | break; |
| 2574 | fb_utils::init_status(tdbb->tdbb_status_vector); |
| 2575 | } |
| 2576 | |
| 2577 | attachment->att_temp_pg_lock = lock; |
| 2578 | } |
| 2579 | |
| 2580 | tempPageSpaceID = (USHORT) attachment->att_temp_pg_lock->getKey(); |
| 2581 | } |
| 2582 | else |
| 2583 | { |
| 2584 | tempPageSpaceID = TEMP_PAGE_SPACE; |
| 2585 | } |
| 2586 | |
| 2587 | addPageSpace(tempPageSpaceID); |
| 2588 | } |
| 2589 | |
| 2590 | USHORT PageManager::getTempPageSpaceID(thread_db* tdbb) |
| 2591 | { |
no test coverage detected