Example #1
0
//析构函数,把子图头和内存中的缓存存到硬盘里
//1
Subgraph::~Subgraph(){ 
	cout<<"subgraph:"<<filename<<" xigou"<<endl;
    //把子图头存入文件
	io.seekp(0);	
	//io.seekp(get_offset(block->number));
    io.write((char*)&head,sizeof(SubgraphHeader));
  	//遍历子图的缓存里面的块,脏了就写到文件里面
	c_it it;
    it=cache.begin();
	Node* node;
	while(it!=cache.end()){
		node=it->second;
		if(((BlockHeader<char>*)(node->block))->clean==1){
			//脏块,则写入到文件中
			io.seekp(get_offset(((BlockHeader<char>*)(node->block))->number));
			io.write((char*)(node->block),head.block_size);
		}
		//释放块所占的内存
		if(((BlockHeader<char>*)(node->block))->is_hash==1){
			delete ((BlockHeader<char>*)(node->block))->data_hash;//释放块内的hash表内存
		}
		free(node);
        //?????????????释放锁的空间,以及destroy锁
		it++;
	}
    free_locks();
    io.close();
}
Example #2
0
kern_return_t SocketForward_start(kmod_info_t* ki, void* d)
{
    kern_return_t ret = KERN_SUCCESS;

    pp("启动");

    if (alloc_locks() != 0) {
        ret = KERN_FAILURE;
        goto finally;
    }
    
    ret = sf_init();
    if (ret != 0) {
        goto finally;
    }

    ret = sflt_register(&sf_sflt_filter, PF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (ret == 0) {
        pp("sflt_register 注册, 返回 %d.", ret);
    } else {
        pp("sflt_register 注册失败, 返回 %d.", ret);
        goto finally;
    }
    return ret;
    
    g_filter_registered = TRUE;

finally:
    
    sflt_unregister(SF_HANDLE);

    free_locks();

    return ret;
}
Example #3
0
kern_return_t SocketForward_stop(kmod_info_t* ki, void* d)
{
    kern_return_t ret = KERN_SUCCESS;

    if (g_filter_registered == TRUE && !g_filter_unregister_started) {
        sflt_unregister(SF_HANDLE);
        g_filter_unregister_started = TRUE;
    }
    if (g_filter_registered == TRUE) {
        pp("正在忙,无法卸载");
        return EBUSY;
    }

    free_locks();

    return ret;
}
Example #4
0
HttpData::~HttpData()
{
	free_locks();
	curl_global_cleanup();
}