Exemplo n.º 1
0
static void  destroy_log(log_t *l)
{
	mutex_lock((*l)->mtx);
	while(!link_list_is_empty((*l)->log_queue))
	{
		wpacket_t w = LINK_LIST_POP(wpacket_t,(*l)->log_queue);
		wpacket_destroy(&w);
	}
	mutex_unlock((*l)->mtx);
	close((*l)->file_descriptor);
	mutex_destroy(&(*l)->mtx);
	destroy_link_list(&(*l)->log_queue);
	destroy_link_list(&(*l)->pending_log);
	free(*l);
	*l = 0;
}
Exemplo n.º 2
0
void free_socket(socket_t *s)
{
	assert(s);assert(*s);
	if((*s)->OnClear_pending_io)
	{
        list_node *tmp;
        while(tmp = link_list_pop((*s)->pending_send))
            (*s)->OnClear_pending_io((st_io*)tmp);
        while(tmp = link_list_pop((*s)->pending_recv))
            (*s)->OnClear_pending_io((st_io*)tmp);
	}
	destroy_link_list(&(*s)->pending_send);
	destroy_link_list(&(*s)->pending_recv);
	free(*s);
	*s = 0;
}
Exemplo n.º 3
0
void close_log_system()
{
	COMPARE_AND_SWAP(&(g_log_system->is_close),0,1);
	//停止写日志线程,并等待结束
	//g_log_system->is_close = 1;
	thread_join(g_log_system->worker_thread);
	mutex_lock(g_log_system->mtx);
	while(!link_list_is_empty(g_log_system->log_files))
	{
		log_t l = LINK_LIST_POP(log_t,g_log_system->log_files);
		destroy_log(&l);
	}
	mutex_unlock(g_log_system->mtx);	
	mutex_destroy(&g_log_system->mtx);
	destroy_link_list(&g_log_system->log_files);
	destroy_thread(&g_log_system->worker_thread);
	//DESTROY(&(g_log_system->_wpacket_allocator));
	free(g_log_system);
	g_log_system = 0;
}