コード例 #1
0
ファイル: mbbstat.c プロジェクト: denispeplin/mbb-devel
void mbb_stat_pool_save(struct mbb_stat_pool *pool)
{
	static GStaticMutex mutex = G_STATIC_MUTEX_INIT;

	mbb_log_lvl_t mask;

	mbb_log_mask(LOG_MASK_DEL, MBB_LOG_QUERY, &mask);

	if (! g_static_mutex_trylock(&mutex)) {
		mbb_log("wait for mutex");
		g_static_mutex_lock(&mutex);
	}

	if (! mbb_task_poll_state())
		goto out;

	mbb_log("save to db");

	if (! db_begin())
		goto out;

	if (! save_records(pool->ustat, unit_rec_save))
		goto rollback;

	if (! save_records(pool->lstat, link_rec_save))
		goto rollback;

	if (! save_records(pool->ulstat, unit_link_rec_save))
		goto rollback;

	db_commit();
	goto out;

rollback:
	db_rollback();
out:
	mbb_log_mask(LOG_MASK_SET, mask, NULL);
	g_static_mutex_unlock(&mutex);
	mbb_stat_pool_free(pool);
}
コード例 #2
0
static void
free_runner (OfficeRunner *run)
{
	if (run->timer)
		g_timer_destroy (run->timer);
	if (run->timeout)
		gtk_widget_remove_tick_callback (run->time_label, run->timeout);
	g_object_unref (run->ui);
	if (run->reenable_block_id > 0)
		g_source_remove (run->reenable_block_id);
	g_clear_object (&run->client);
	if (run->lid_switch_fd > 0)
		close (run->lid_switch_fd);
	g_object_unref (run->connection);

	if (run->dirty_records) {
		save_records (run);
	}

	g_list_free_full (run->records, (GDestroyNotify) free_orecord);

	g_free (run);
}