Beispiel #1
0
/**
 * Initialize node stability caching.
 */
G_GNUC_COLD void
stable_init(void)
{
    dbstore_kv_t kv = { KUID_RAW_SIZE, NULL, sizeof(struct lifedata), 0 };
    dbstore_packing_t packing =
    { serialize_lifedata, deserialize_lifedata, NULL };

    g_assert(NULL == db_lifedata);
    g_assert(NULL == stable_sync_ev);
    g_assert(NULL == stable_prune_ev);

    /* Legacy: remove after 0.97 -- RAM, 2011-05-03 */
    dbstore_move(settings_config_dir(), settings_dht_db_dir(), db_stable_base);

    db_lifedata = dbstore_open(db_stable_what, settings_dht_db_dir(),
                               db_stable_base, kv, packing, STABLE_DB_CACHE_SIZE, kuid_hash, kuid_eq,
                               GNET_PROPERTY(dht_storage_in_memory));

    dbmw_set_map_cache(db_lifedata, STABLE_MAP_CACHE_SIZE);
    stable_prune_old();

    stable_sync_ev = cq_periodic_main_add(STABLE_SYNC_PERIOD,
                                          stable_sync, NULL);

    stable_prune_ev = cq_periodic_main_add(STABLE_PRUNE_PERIOD,
                                           stable_periodic_prune, NULL);
}
Beispiel #2
0
/**
 * Initialize security token caching.
 */
G_GNUC_COLD void
tcache_init(void)
{
	dbstore_kv_t kv = { KUID_RAW_SIZE, NULL, sizeof(struct tokdata),
		sizeof(struct tokdata) + MAX_INT_VAL(uint8) };
	dbstore_packing_t packing =
		{ serialize_tokdata, deserialize_tokdata, free_tokdata };

	g_assert(NULL == db_tokdata);
	g_assert(NULL == tcache_prune_ev);

	/* Legacy: remove after 0.97 -- RAM, 2011-05-03 */
	dbstore_move(settings_config_dir(), settings_dht_db_dir(), db_tcache_base);

	db_tokdata = dbstore_create(db_tcache_what, settings_dht_db_dir(),
		db_tcache_base, kv, packing, TOK_DB_CACHE_SIZE, kuid_hash, kuid_eq,
		GNET_PROPERTY(dht_storage_in_memory));

	dbmw_set_map_cache(db_tokdata, TOK_MAP_CACHE_SIZE);
	dbmw_set_debugging(db_tokdata, &tcache_dbmw_dbg);

	token_life = MIN(TOK_LIFE, token_lifetime());

	if (GNET_PROPERTY(dht_tcache_debug))
		g_debug("DHT cached token lifetime set to %u secs",
			(unsigned) token_life);

	tcache_prune_ev = cq_periodic_main_add(TCACHE_PRUNE_PERIOD,
		tcache_periodic_prune, NULL);
}