Exemple #1
0
void
network_server_clean(struct network_server_s *srv)
{
	if (!srv)
		return;

	if (srv->thread_events != NULL) {
		GRID_WARN("EventThread not joined!");
		g_error("EventThread not joined!");
	}
	if (srv->thread_first_worker) {
		GRID_WARN("FirstThread not joined!");
		g_error("FirstThread not joined!");
	}

	g_mutex_clear(&srv->lock_threads);

	network_server_close_servers(srv);

	if (srv->endpointv) {
		struct endpoint_s **u;
		for (u=srv->endpointv; *u ;u++)
			g_free(*u);
		g_free(srv->endpointv);
	}

	if (srv->stats) {
		grid_stats_holder_clean(srv->stats);
	}

	metautils_pclose(&(srv->wakeup[0]));
	metautils_pclose(&(srv->wakeup[1]));

	if (srv->queue_monitor) {
		g_async_queue_unref(srv->queue_monitor);
		srv->queue_monitor = NULL;
	}

	if (srv->queue_events) {
		g_async_queue_unref(srv->queue_events);
		srv->queue_events = NULL;
	}

	if (srv->workers_active_1) {
		grid_single_rrd_destroy(srv->workers_active_1);
		srv->workers_active_1 = NULL;
	}
	if (srv->workers_active_60) {
		grid_single_rrd_destroy(srv->workers_active_60);
		srv->workers_active_60 = NULL;
	}

	g_free(srv);
}
Exemple #2
0
static void
test_rrd (void)
{
	struct grid_single_rrd_s *rrd = grid_single_rrd_create(2, 60);
	grid_single_rrd_push(rrd, 3, 0);
	grid_single_rrd_push(rrd, 1000, 0);
	grid_single_rrd_push(rrd, 2, 0);
	grid_single_rrd_destroy(rrd);
}
Exemple #3
0
static void
sqlx_service_specific_fini(void)
{
	// soft stop
	if (SRV.gtq_reload)
		grid_task_queue_stop(SRV.gtq_reload);
	if (SRV.gtq_register)
		grid_task_queue_stop(SRV.gtq_register);
	if (SRV.gtq_admin)
		grid_task_queue_stop(SRV.gtq_admin);

	if (SRV.server) {
		network_server_close_servers(SRV.server);
		network_server_stop(SRV.server);
	}

	if (SRV.thread_reload)
		g_thread_join(SRV.thread_reload);
	if (SRV.thread_register)
		g_thread_join(SRV.thread_register);
	if (SRV.thread_admin)
		g_thread_join(SRV.thread_admin);
	if (SRV.thread_client)
		g_thread_join(SRV.thread_client);
	if (SRV.thread_queue)
		g_thread_join(SRV.thread_queue);

	if (SRV.repository) {
		sqlx_repository_stop(SRV.repository);
		struct sqlx_cache_s *cache = sqlx_repository_get_cache(SRV.repository);
		if (cache)
			sqlx_cache_expire(cache, G_MAXUINT, 0);
	}
	if (SRV.election_manager)
		election_manager_exit_all(SRV.election_manager, 0, TRUE);
	if (SRV.sync)
		sqlx_sync_close(SRV.sync);

	// Cleanup
	if (SRV.gtq_admin)
		grid_task_queue_destroy(SRV.gtq_admin);
	if (SRV.gtq_reload)
		grid_task_queue_destroy(SRV.gtq_reload);
	if (SRV.gtq_register)
		grid_task_queue_destroy(SRV.gtq_register);

	if (SRV.server)
		network_server_clean(SRV.server);
	if (SRV.dispatcher)
		gridd_request_dispatcher_clean(SRV.dispatcher);
	if (SRV.repository)
		sqlx_repository_clean(SRV.repository);
	if (SRV.election_manager)
		election_manager_clean(SRV.election_manager);
	if (SRV.sync)
		sqlx_sync_clear(SRV.sync);
	if (SRV.resolver)
		hc_resolver_destroy(SRV.resolver);

	if (SRV.gsr_reqtime)
		grid_single_rrd_destroy(SRV.gsr_reqtime);
	if (SRV.gsr_reqcounter)
		grid_single_rrd_destroy(SRV.gsr_reqcounter);

	if (SRV.custom_tags)
		g_slist_free_full(SRV.custom_tags, g_free);
	if (SRV.si)
		service_info_clean(SRV.si);
	if (SRV.announce)
		g_string_free(SRV.announce, TRUE);
	if (SRV.url)
		g_string_free(SRV.url, TRUE);
	if (SRV.zk_url)
		oio_str_clean(&SRV.zk_url);

	if (SRV.clients_pool)
		gridd_client_pool_destroy (SRV.clients_pool);

	if (SRV.lb)
		grid_lbpool_destroy (SRV.lb);

	if (SRV.events_queue)
		oio_events_queue__destroy (SRV.events_queue);

	if (SRV.nsinfo)
		namespace_info_free(SRV.nsinfo);
	if (all_options) {
		g_free (all_options);
		all_options = NULL;
	}
}