| 1458 | */ |
| 1459 | |
| 1460 | static void unlink_hash(KEY_CACHE *keycache, HASH_LINK *hash_link) |
| 1461 | { |
| 1462 | KEYCACHE_DBUG_PRINT("unlink_hash", ("fd: %u pos_ %lu #requests=%u", |
| 1463 | (uint) hash_link->file,(ulong) hash_link->diskpos, hash_link->requests)); |
| 1464 | KEYCACHE_DBUG_ASSERT(hash_link->requests == 0); |
| 1465 | if ((*hash_link->prev= hash_link->next)) |
| 1466 | hash_link->next->prev= hash_link->prev; |
| 1467 | hash_link->block= NULL; |
| 1468 | |
| 1469 | if (keycache->waiting_for_hash_link.last_thread) |
| 1470 | { |
| 1471 | /* Signal that a free hash link has appeared */ |
| 1472 | struct st_my_thread_var *last_thread= |
| 1473 | keycache->waiting_for_hash_link.last_thread; |
| 1474 | struct st_my_thread_var *first_thread= last_thread->next; |
| 1475 | struct st_my_thread_var *next_thread= first_thread; |
| 1476 | KEYCACHE_PAGE *first_page= (KEYCACHE_PAGE *) (first_thread->opt_info); |
| 1477 | struct st_my_thread_var *thread; |
| 1478 | |
| 1479 | hash_link->file= first_page->file; |
| 1480 | hash_link->diskpos= first_page->filepos; |
| 1481 | do |
| 1482 | { |
| 1483 | KEYCACHE_PAGE *page; |
| 1484 | thread= next_thread; |
| 1485 | page= (KEYCACHE_PAGE *) thread->opt_info; |
| 1486 | next_thread= thread->next; |
| 1487 | /* |
| 1488 | We notify about the event all threads that ask |
| 1489 | for the same page as the first thread in the queue |
| 1490 | */ |
| 1491 | if (page->file == hash_link->file && page->filepos == hash_link->diskpos) |
| 1492 | { |
| 1493 | KEYCACHE_DBUG_PRINT("unlink_hash: signal", ("thread %ld", thread->id)); |
| 1494 | keycache_pthread_cond_signal(&thread->suspend); |
| 1495 | unlink_from_queue(&keycache->waiting_for_hash_link, thread); |
| 1496 | } |
| 1497 | } |
| 1498 | while (thread != last_thread); |
| 1499 | link_hash(&keycache->hash_root[KEYCACHE_HASH(hash_link->file, |
| 1500 | hash_link->diskpos)], |
| 1501 | hash_link); |
| 1502 | return; |
| 1503 | } |
| 1504 | hash_link->next= keycache->free_hash_list; |
| 1505 | keycache->free_hash_list= hash_link; |
| 1506 | } |
| 1507 | |
| 1508 | |
| 1509 | /* |
no test coverage detected