From a8635f7e292be02a31f64fedbc8ca79e24c809d4 Mon Sep 17 00:00:00 2001 From: marko Date: Mon, 5 Nov 2007 10:31:41 +0000 Subject: [PATCH] branches/zip: buf_page_get_gen(): Ignore "guess" if it does not point to buf_pool->chunks[]->blocks[]. buf_block_is_uncompressed(): New function, to detect if a block points to buf_pool->chunks[]->blocks[]. --- buf/buf0buf.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/buf/buf0buf.c b/buf/buf0buf.c index eeb4651b776..a9c8e510e80 100644 --- a/buf/buf0buf.c +++ b/buf/buf0buf.c @@ -1654,6 +1654,36 @@ buf_zip_decompress( return(FALSE); } +/************************************************************************ +Find out if a buffer block was created by buf_chunk_init(). */ +static +ibool +buf_block_is_uncompressed( +/*======================*/ + /* out: TRUE if "block" has + been added to buf_pool->free + by buf_chunk_init() */ + const buf_block_t* block) /* in: pointer to block, + not dereferenced */ +{ + const buf_chunk_t* chunk = buf_pool->chunks; + const buf_chunk_t* const echunk = chunk + buf_pool->n_chunks; + + ut_ad(mutex_own(&buf_pool->mutex)); + + while (chunk < echunk) { + if (block >= chunk->blocks + && block < chunk->blocks + chunk->size) { + + return(TRUE); + } + + chunk++; + } + + return(FALSE); +} + /************************************************************************ This is the general function used to get access to a database page. */ @@ -1696,11 +1726,21 @@ loop: mutex_enter_fast(&(buf_pool->mutex)); if (block) { - if (offset != block->page.offset + /* If this is a compressed page descriptor that + has been allocated by buf_buddy_alloc(), it may have + been invalidated by buf_buddy_relocate(). In that + case, block could point to something that happens to + contain the expected bits in block->page. */ + + if (!buf_block_is_uncompressed(block) + || offset != block->page.offset || space != block->page.space - || !buf_page_in_file(&block->page)) { + || buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE) { block = guess = NULL; + } else { + ut_ad(!block->page.in_zip_hash); + ut_ad(block->page.in_page_hash); } } @@ -1759,7 +1799,6 @@ wait_until_unfixed: mutex_exit(&buf_pool->mutex); os_thread_sleep(WAIT_FOR_READ); - guess = block; goto loop; }