/* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ tb_bool_t tb_dns_cache_init() { // enter tb_spinlock_enter(&g_lock); // done tb_bool_t ok = tb_false; do { // init hash if (!g_cache.hash) g_cache.hash = tb_hash_init(tb_align8(tb_isqrti(TB_DNS_CACHE_MAXN) + 1), tb_item_func_str(tb_false), tb_item_func_mem(sizeof(tb_dns_cache_addr_t), tb_null, tb_null)); tb_assert_and_check_break(g_cache.hash); // ok ok = tb_true; } while (0); // leave tb_spinlock_leave(&g_lock); // failed? exit it if (!ok) tb_dns_cache_exit(); // ok? return ok; }
tb_void_t tb_network_exit() { // exit dns cache tb_dns_cache_exit(); // exit dns server tb_dns_server_exit(); }