Example #1
0
int trove_handle_mgmt_finalize()
{
    int i;
    handle_ledger_t *ledger = NULL;
    struct qlist_head *hash_link = NULL;

    gen_mutex_lock(&trove_handle_mutex);
    /*
      this is an exhaustive and slow iterate.  speed this up
      if 'finalize' is something that will be done frequently.
    */
    for (i = 0; i < s_fsid_to_ledger_table->table_size; i++)
    {
        do
        {
            hash_link =
                qhash_search_and_remove_at_index(s_fsid_to_ledger_table, i);
            if (hash_link)
            {
                ledger = qlist_entry(hash_link, handle_ledger_t, hash_link);
                assert(ledger);
                assert(ledger->ledger);

                trove_handle_ledger_free(ledger->ledger);
                free(ledger);
            }
        } while(hash_link);
    }
    qhash_finalize(s_fsid_to_ledger_table);
    s_fsid_to_ledger_table = NULL;

    gen_mutex_unlock(&trove_handle_mutex);
    return 0;
}
Example #2
0
int pvfs2_mmap_ra_cache_finalize(void)
{
    int ret = -1, i = 0;

    struct qlist_head *hash_link = NULL;
    mmap_ra_cache_elem_t *cache_elem = NULL;

    if (MMAP_RA_CACHE_INITIALIZED())
    {
        gen_mutex_lock(&s_mmap_ra_cache_mutex);
        for(i = 0; i < s_key_to_data_table->table_size; i++)
        {
            do
            {
                hash_link = qhash_search_and_remove_at_index(
                    s_key_to_data_table,i);
                if (hash_link)
                {
                    cache_elem = qhash_entry(
                        hash_link, mmap_ra_cache_elem_t, hash_link);

                    assert(cache_elem);
                    assert(cache_elem->data);

                    free(cache_elem->data);
                    free(cache_elem);
                }
            } while(hash_link);
        }

        ret = 0;
        qhash_finalize(s_key_to_data_table);
        s_key_to_data_table = NULL;
        gen_mutex_unlock(&s_mmap_ra_cache_mutex);

        /* FIXME: race condition here */
        gen_mutex_destroy(&s_mmap_ra_cache_mutex);
        gossip_debug(GOSSIP_MMAP_RCACHE_DEBUG, "mmap_ra_cache_finalized\n");
    }
    return ret;
}