| 1327 | */ |
| 1328 | |
| 1329 | static void unreg_request(KEY_CACHE *keycache, |
| 1330 | BLOCK_LINK *block, int at_end) |
| 1331 | { |
| 1332 | DBUG_ASSERT(block->status & (BLOCK_READ | BLOCK_IN_USE)); |
| 1333 | DBUG_ASSERT(block->hash_link); /*backptr to block NULL from free_block()*/ |
| 1334 | DBUG_ASSERT(block->requests); |
| 1335 | DBUG_ASSERT(block->prev_changed && *block->prev_changed == block); |
| 1336 | DBUG_ASSERT(!block->next_used); |
| 1337 | DBUG_ASSERT(!block->prev_used); |
| 1338 | /* |
| 1339 | Unregister the request, but do not link erroneous blocks into the |
| 1340 | LRU ring. |
| 1341 | */ |
| 1342 | if (!--block->requests && !(block->status & BLOCK_ERROR)) |
| 1343 | { |
| 1344 | my_bool hot; |
| 1345 | if (block->hits_left) |
| 1346 | block->hits_left--; |
| 1347 | hot= !block->hits_left && at_end && |
| 1348 | keycache->warm_blocks > keycache->min_warm_blocks; |
| 1349 | if (hot) |
| 1350 | { |
| 1351 | if (block->temperature == BLOCK_WARM) |
| 1352 | keycache->warm_blocks--; |
| 1353 | block->temperature= BLOCK_HOT; |
| 1354 | KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks: %lu", |
| 1355 | keycache->warm_blocks)); |
| 1356 | } |
| 1357 | link_block(keycache, block, hot, (my_bool)at_end); |
| 1358 | block->last_hit_time= keycache->keycache_time; |
| 1359 | keycache->keycache_time++; |
| 1360 | /* |
| 1361 | At this place, the block might be in the LRU ring or not. If an |
| 1362 | evicter was waiting for a block, it was selected for eviction and |
| 1363 | not linked in the LRU ring. |
| 1364 | */ |
| 1365 | |
| 1366 | /* |
| 1367 | Check if we should link a hot block to the warm block sub-chain. |
| 1368 | It is possible that we select the same block as above. But it can |
| 1369 | also be another block. In any case a block from the LRU ring is |
| 1370 | selected. In other words it works even if the above block was |
| 1371 | selected for eviction and not linked in the LRU ring. Since this |
| 1372 | happens only if the LRU ring is empty, the block selected below |
| 1373 | would be NULL and the rest of the function skipped. |
| 1374 | */ |
| 1375 | block= keycache->used_ins; |
| 1376 | if (block && keycache->keycache_time - block->last_hit_time > |
| 1377 | keycache->age_threshold) |
| 1378 | { |
| 1379 | unlink_block(keycache, block); |
| 1380 | link_block(keycache, block, 0, 0); |
| 1381 | if (block->temperature != BLOCK_WARM) |
| 1382 | { |
| 1383 | keycache->warm_blocks++; |
| 1384 | block->temperature= BLOCK_WARM; |
| 1385 | } |
| 1386 | KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks: %lu", |
no test coverage detected