* tsd_exit - destroys all thread specific data for this thread * * Destroys all the thread specific data for this thread. * * Caller must prevent racing tsd_set() or tsd_get(), this function is * safe from racing tsd_create(), tsd_destroy(), and tsd_exit(). */
| 648 | * safe from racing tsd_create(), tsd_destroy(), and tsd_exit(). |
| 649 | */ |
| 650 | void |
| 651 | tsd_exit(void) |
| 652 | { |
| 653 | HLIST_HEAD(work); |
| 654 | tsd_hash_table_t *table; |
| 655 | tsd_hash_entry_t *pid_entry, *entry; |
| 656 | tsd_hash_bin_t *pid_entry_bin, *entry_bin; |
| 657 | ulong_t hash; |
| 658 | |
| 659 | table = tsd_hash_table; |
| 660 | ASSERT3P(table, !=, NULL); |
| 661 | |
| 662 | spin_lock(&table->ht_lock); |
| 663 | pid_entry = tsd_hash_search(table, PID_KEY, curthread->pid); |
| 664 | if (pid_entry == NULL) { |
| 665 | spin_unlock(&table->ht_lock); |
| 666 | return; |
| 667 | } |
| 668 | |
| 669 | /* |
| 670 | * All keys associated with this pid must be linked off of the |
| 671 | * PID_KEY entry. They are removed from the hash table and |
| 672 | * linked in to a private working list to be destroyed. |
| 673 | */ |
| 674 | |
| 675 | while (!list_empty(&pid_entry->he_pid_list)) { |
| 676 | entry = list_entry(pid_entry->he_pid_list.next, |
| 677 | tsd_hash_entry_t, he_pid_list); |
| 678 | ASSERT3U(pid_entry->he_pid, ==, entry->he_pid); |
| 679 | |
| 680 | hash = hash_long((ulong_t)entry->he_key * |
| 681 | (ulong_t)entry->he_pid, table->ht_bits); |
| 682 | entry_bin = &table->ht_bins[hash]; |
| 683 | |
| 684 | spin_lock(&entry_bin->hb_lock); |
| 685 | tsd_hash_del(table, entry); |
| 686 | hlist_add_head(&entry->he_list, &work); |
| 687 | spin_unlock(&entry_bin->hb_lock); |
| 688 | } |
| 689 | |
| 690 | hash = hash_long((ulong_t)pid_entry->he_key * |
| 691 | (ulong_t)pid_entry->he_pid, table->ht_bits); |
| 692 | pid_entry_bin = &table->ht_bins[hash]; |
| 693 | |
| 694 | spin_lock(&pid_entry_bin->hb_lock); |
| 695 | tsd_hash_del(table, pid_entry); |
| 696 | hlist_add_head(&pid_entry->he_list, &work); |
| 697 | spin_unlock(&pid_entry_bin->hb_lock); |
| 698 | spin_unlock(&table->ht_lock); |
| 699 | |
| 700 | tsd_hash_dtor(&work); |
| 701 | } |
| 702 | EXPORT_SYMBOL(tsd_exit); |
| 703 | |
| 704 | int |
no test coverage detected