Esempio n. 1
0
/*
 * bc_close() is not thread safe, should stop other threads before call it.
 * */
void bc_close(Bitcask *bc)
{
    int i=0;
    pthread_mutex_lock(&bc->write_lock);
    bc_flush(bc, 0, 0);
    
    if (NULL != bc->curr_tree) {
        uint32_t curr;
        ht_get_hash(bc->curr_tree, "@", &curr);
        if (curr > 0) {
            char name[255], buf[255];
            sprintf(name, HINT_FILE, bc->curr);
            sprintf(buf, "%s/%s", mgr_alloc(bc->mgr, name), name);
            build_hint(bc->curr_tree, buf);
        }else{
            ht_destroy(bc->curr_tree);
        }
        bc->curr_tree = NULL;
    }
    bc->curr = 0;
    ht_destroy(bc->tree);
    mgr_destroy(bc->mgr);
    free(bc->write_buffer);
    free(bc);
}
Esempio n. 2
0
/*
 *  ======== dsp_deinit ========
 *  	Frees the resources allocated for bridge.
 */
bool dsp_deinit(u32 device_context)
{
	bool ret = true;
	u32 device_node;
	struct mgr_object *mgr_obj = NULL;
	struct drv_data *drv_datap = dev_get_drvdata(bridge);

	while ((device_node = drv_get_first_dev_extension()) != 0) {
		(void)dev_remove_device((struct cfg_devnode *)device_node);

		(void)drv_release_resources((u32) device_node,
					(struct drv_object *)device_context);
	}

	(void)drv_destroy((struct drv_object *)device_context);

	/* Get the Manager Object from driver data
	 * MGR Destroy will unload the DCD dll */
	if (drv_datap && drv_datap->mgr_object) {
		mgr_obj = drv_datap->mgr_object;
		(void)mgr_destroy(mgr_obj);
	} else {
		pr_err("%s: Failed to retrieve the object handle\n", __func__);
	}

	api_exit();

	return ret;
}
Esempio n. 3
0
/*
 * bc_close() is not thread safe, should stop other threads before call it.
 * */
void bc_close(Bitcask *bc)
{
    char datapath[255], hintpath[255];

    if (bc->optimize_flag > 0)
    {
        bc->optimize_flag = 2;
        while (bc->optimize_flag > 0)
        {
            sleep(1);
        }
    }

    pthread_mutex_lock(&bc->write_lock);

    bc_flush(bc, 0, 0);

    if (NULL != bc->curr_tree)
    {
        if (bc->curr_bytes > 0)
        {
            build_hint(bc->curr_tree, new_path(hintpath, bc->mgr, HINT_FILE, bc->curr));
        }
        else
        {
            ht_destroy(bc->curr_tree);
        }
        bc->curr_tree = NULL;
    }

    if (bc->curr_bytes == 0) bc->curr --;
    if (bc->curr - bc->last_snapshot >= SAVE_HTREE_LIMIT)
    {
        if (ht_save(bc->tree, new_path(datapath, bc->mgr, HTREE_FILE, bc->curr)) == 0)
        {
            mgr_unlink(gen_path(datapath, mgr_base(bc->mgr), HTREE_FILE, bc->last_snapshot));
        }
        else
        {
            fprintf(stderr, "save HTree to %s failed\n", datapath);
        }
    }
    ht_destroy(bc->tree);

    mgr_destroy(bc->mgr);
    free(bc->write_buffer);
    free(bc);
}
Esempio n. 4
0
void hs_close(HStore *store)
{
    int i;
    if (!store) return;
    // stop optimizing
    store->op_start = store->op_end = 0;
    
    if (store->scan_threads > 1 && store->count > 1) {
        parallelize(store, bc_close);
    } else {
        for (i=0; i<store->count; i++){
            bc_close(store->bitcasks[i]);
        }
    }
    mgr_destroy(store->mgr);
    free(store);
}
Esempio n. 5
0
/*
 *  ======== dsp_deinit ========
 *  	Frees the resources allocated for bridge.
 */
bool dsp_deinit(u32 deviceContext)
{
	bool ret = true;
	u32 device_node;
	struct mgr_object *mgr_obj = NULL;

	while ((device_node = drv_get_first_dev_extension()) != 0) {
		(void)dev_remove_device((struct cfg_devnode *)device_node);

		(void)drv_release_resources((u32) device_node,
					    (struct drv_object *)deviceContext);
	}

	(void)drv_destroy((struct drv_object *)deviceContext);

	/* Get the Manager Object from Registry
	 * MGR Destroy will unload the DCD dll */
	if (DSP_SUCCEEDED(cfg_get_object((u32 *) &mgr_obj, REG_MGR_OBJECT)))
		(void)mgr_destroy(mgr_obj);

	wcd_exit();

	return ret;
}