void irs_resconf_destroy(irs_resconf_t **confp) { irs_resconf_t *conf; isc_sockaddr_t *address; irs_resconf_search_t *searchentry; int i; REQUIRE(confp != NULL); conf = *confp; REQUIRE(IRS_RESCONF_VALID(conf)); while ((searchentry = ISC_LIST_HEAD(conf->searchlist)) != NULL) { ISC_LIST_UNLINK(conf->searchlist, searchentry, link); isc_mem_put(conf->mctx, searchentry, sizeof(*searchentry)); } while ((address = ISC_LIST_HEAD(conf->nameservers)) != NULL) { ISC_LIST_UNLINK(conf->nameservers, address, link); isc_mem_put(conf->mctx, address, sizeof(*address)); } if (conf->domainname != NULL) isc_mem_free(conf->mctx, conf->domainname); for (i = 0; i < RESCONFMAXSEARCH; i++) { if (conf->search[i] != NULL) isc_mem_free(conf->mctx, conf->search[i]); } isc_mem_put(conf->mctx, conf, sizeof(*conf)); *confp = NULL; }
static void destroynode(dns_ecdbnode_t *node) { isc_mem_t *mctx; dns_ecdb_t *ecdb = node->ecdb; isc_boolean_t need_destroydb = ISC_FALSE; rdatasetheader_t *header; mctx = ecdb->common.mctx; LOCK(&ecdb->lock); ISC_LIST_UNLINK(ecdb->nodes, node, link); if (ecdb->references == 0 && ISC_LIST_EMPTY(ecdb->nodes)) need_destroydb = ISC_TRUE; UNLOCK(&ecdb->lock); dns_name_free(&node->name, mctx); while ((header = ISC_LIST_HEAD(node->rdatasets)) != NULL) { unsigned int headersize; ISC_LIST_UNLINK(node->rdatasets, header, link); headersize = dns_rdataslab_size((unsigned char *)header, sizeof(*header)); isc_mem_put(mctx, header, headersize); } DESTROYLOCK(&node->lock); node->magic = 0; isc_mem_put(mctx, node, sizeof(*node)); if (need_destroydb) destroy_ecdb(&ecdb); }
isc_boolean_t key_collision(isc_uint16_t id, dns_name_t *name, const char *dir, dns_secalg_t alg, isc_mem_t *mctx, isc_boolean_t *exact) { isc_result_t result; isc_boolean_t conflict = ISC_FALSE; dns_dnsseckeylist_t matchkeys; dns_dnsseckey_t *key = NULL; isc_uint16_t oldid, diff; isc_uint16_t bits = DNS_KEYFLAG_REVOKE; /* flag bits to look for */ if (exact != NULL) *exact = ISC_FALSE; ISC_LIST_INIT(matchkeys); result = dns_dnssec_findmatchingkeys(name, dir, mctx, &matchkeys); if (result == ISC_R_NOTFOUND) return (ISC_FALSE); while (!ISC_LIST_EMPTY(matchkeys) && !conflict) { key = ISC_LIST_HEAD(matchkeys); if (dst_key_alg(key->key) != alg) goto next; oldid = dst_key_id(key->key); diff = (oldid > id) ? (oldid - id) : (id - oldid); if ((diff & ~bits) == 0) { conflict = ISC_TRUE; if (diff != 0) { if (verbose > 1) fprintf(stderr, "Key ID %d could " "collide with %d\n", id, oldid); } else { if (exact != NULL) *exact = ISC_TRUE; if (verbose > 1) fprintf(stderr, "Key ID %d exists\n", id); } } next: ISC_LIST_UNLINK(matchkeys, key, link); dns_dnsseckey_destroy(mctx, &key); } /* Finish freeing the list */ while (!ISC_LIST_EMPTY(matchkeys)) { key = ISC_LIST_HEAD(matchkeys); ISC_LIST_UNLINK(matchkeys, key, link); dns_dnsseckey_destroy(mctx, &key); } return (conflict); }
isc_result_t dns_db_updatenotify_unregister(dns_db_t *db, dns_dbupdate_callback_t fn, void *fn_arg) { dns_dbonupdatelistener_t *listener; REQUIRE(db != NULL); for (listener = ISC_LIST_HEAD(db->update_listeners); listener != NULL; listener = ISC_LIST_NEXT(listener, link)) { if ((listener->onupdate == fn) && (listener->onupdate_arg == fn_arg)) { ISC_LIST_UNLINK(db->update_listeners, listener, link); isc_mem_put(db->mctx, listener, sizeof(dns_dbonupdatelistener_t)); return (ISC_R_SUCCESS); } } return (ISC_R_NOTFOUND); }
void cfg_aclconfctx_detach(cfg_aclconfctx_t **actxp) { cfg_aclconfctx_t *actx; dns_acl_t *dacl, *next; unsigned int refs; REQUIRE(actxp != NULL && *actxp != NULL); actx = *actxp; isc_refcount_decrement(&actx->references, &refs); if (refs == 0) { for (dacl = ISC_LIST_HEAD(actx->named_acl_cache); dacl != NULL; dacl = next) { next = ISC_LIST_NEXT(dacl, nextincache); ISC_LIST_UNLINK(actx->named_acl_cache, dacl, nextincache); dns_acl_detach(&dacl); } isc_mem_putanddetach(&actx->mctx, actx, sizeof(*actx)); } *actxp = NULL; }
static void lookup_callback(isc_task_t *task, isc_event_t *ev) { client_t *client; client = ev->ev_arg; INSIST(client->find == ev->ev_sender); printf("NAME %s:\n\tTask %p got event %p type %08x from %p, client %p\n\terr4: %s err6: %s\n", client->target, task, ev, ev->ev_type, client->find, client, isc_result_totext(client->find->result_v4), isc_result_totext(client->find->result_v6)); isc_event_free(&ev); ev = NULL; CLOCK(); dns_adb_dumpfind(client->find, stderr); dns_adb_destroyfind(&client->find); ISC_LIST_UNLINK(clients, client, link); free_client(&client); CUNLOCK(); }
static isc_result_t add_rdata_to_list(dns_message_t *msg, dns_name_t *name, dns_rdata_t *rdata, isc_uint32_t ttl, dns_namelist_t *namelist) { isc_result_t result; isc_region_t r, newr; dns_rdata_t *newrdata = NULL; dns_name_t *newname = NULL; dns_rdatalist_t *newlist = NULL; dns_rdataset_t *newset = NULL; isc_buffer_t *tmprdatabuf = NULL; RETERR(dns_message_gettemprdata(msg, &newrdata)); dns_rdata_toregion(rdata, &r); RETERR(isc_buffer_allocate(msg->mctx, &tmprdatabuf, r.length)); isc_buffer_availableregion(tmprdatabuf, &newr); memcpy(newr.base, r.base, r.length); dns_rdata_fromregion(newrdata, rdata->rdclass, rdata->type, &newr); dns_message_takebuffer(msg, &tmprdatabuf); RETERR(dns_message_gettempname(msg, &newname)); dns_name_init(newname, NULL); RETERR(dns_name_dup(name, msg->mctx, newname)); RETERR(dns_message_gettemprdatalist(msg, &newlist)); newlist->rdclass = newrdata->rdclass; newlist->type = newrdata->type; newlist->covers = 0; newlist->ttl = ttl; ISC_LIST_INIT(newlist->rdata); ISC_LIST_APPEND(newlist->rdata, newrdata, link); RETERR(dns_message_gettemprdataset(msg, &newset)); dns_rdataset_init(newset); RETERR(dns_rdatalist_tordataset(newlist, newset)); ISC_LIST_INIT(newname->list); ISC_LIST_APPEND(newname->list, newset, link); ISC_LIST_APPEND(*namelist, newname, link); return (ISC_R_SUCCESS); failure: if (newrdata != NULL) { if (ISC_LINK_LINKED(newrdata, link)) ISC_LIST_UNLINK(newlist->rdata, newrdata, link); dns_message_puttemprdata(msg, &newrdata); } if (newname != NULL) dns_message_puttempname(msg, &newname); if (newset != NULL) { dns_rdataset_disassociate(newset); dns_message_puttemprdataset(msg, &newset); } if (newlist != NULL) dns_message_puttemprdatalist(msg, &newlist); return (result); }
/* * XXX uses qsort(); a merge sort would be more natural for lists, * and perhaps safer wrt thread stack overflow. */ isc_result_t dns_diff_sort(dns_diff_t *diff, dns_diff_compare_func *compare) { unsigned int length = 0; unsigned int i; dns_difftuple_t **v; dns_difftuple_t *p; REQUIRE(DNS_DIFF_VALID(diff)); for (p = ISC_LIST_HEAD(diff->tuples); p != NULL; p = ISC_LIST_NEXT(p, link)) length++; if (length == 0) return (ISC_R_SUCCESS); v = isc_mem_get(diff->mctx, length * sizeof(dns_difftuple_t *)); if (v == NULL) return (ISC_R_NOMEMORY); for (i = 0; i < length; i++) { p = ISC_LIST_HEAD(diff->tuples); v[i] = p; ISC_LIST_UNLINK(diff->tuples, p, link); } INSIST(ISC_LIST_HEAD(diff->tuples) == NULL); qsort(v, length, sizeof(v[0]), compare); for (i = 0; i < length; i++) { ISC_LIST_APPEND(diff->tuples, v[i], link); } isc_mem_put(diff->mctx, v, length * sizeof(dns_difftuple_t *)); return (ISC_R_SUCCESS); }
static inline void destroy(dns_ssutable_t *table) { isc_mem_t *mctx; REQUIRE(VALID_SSUTABLE(table)); mctx = table->mctx; while (!ISC_LIST_EMPTY(table->rules)) { dns_ssurule_t *rule = ISC_LIST_HEAD(table->rules); if (rule->identity != NULL) { dns_name_free(rule->identity, mctx); isc_mem_put(mctx, rule->identity, sizeof(dns_name_t)); } if (rule->name != NULL) { dns_name_free(rule->name, mctx); isc_mem_put(mctx, rule->name, sizeof(dns_name_t)); } if (rule->types != NULL) isc_mem_put(mctx, rule->types, rule->ntypes * sizeof(dns_rdatatype_t)); ISC_LIST_UNLINK(table->rules, rule, link); rule->magic = 0; isc_mem_put(mctx, rule, sizeof(dns_ssurule_t)); } DESTROYLOCK(&table->lock); table->magic = 0; isc_mem_putanddetach(&table->mctx, table, sizeof(dns_ssutable_t)); }
void isc_ratelimiter_shutdown (isc_ratelimiter_t * rl) { isc_event_t *ev; isc_task_t *task; LOCK (&rl->lock); rl->state = isc_ratelimiter_shuttingdown; (void) isc_timer_reset (rl->timer, isc_timertype_inactive, NULL, NULL, ISC_FALSE); while ((ev = ISC_LIST_HEAD (rl->pending)) != NULL) { ISC_LIST_UNLINK (rl->pending, ev, ev_link); ev->ev_attributes |= ISC_EVENTATTR_CANCELED; task = ev->ev_sender; isc_task_send (task, &ev); } isc_timer_detach (&rl->timer); /* * Send an event to our task. The delivery of this event * indicates that no more timer events will be delivered. */ ev = &rl->shutdownevent; isc_task_send (rl->task, &ev); UNLOCK (&rl->lock); }
void ns_lwsearchlist_detach(ns_lwsearchlist_t **listp) { ns_lwsearchlist_t *list; isc_mem_t *mctx; REQUIRE(listp != NULL); list = *listp; REQUIRE(VALID_LWSEARCHLIST(list)); LOCK(&list->lock); INSIST(list->refs > 0); list->refs--; UNLOCK(&list->lock); *listp = NULL; if (list->refs != 0) return; mctx = list->mctx; while (!ISC_LIST_EMPTY(list->names)) { dns_name_t *name = ISC_LIST_HEAD(list->names); ISC_LIST_UNLINK(list->names, name, link); dns_name_free(name, list->mctx); isc_mem_put(list->mctx, name, sizeof(dns_name_t)); } list->magic = 0; isc_mem_put(mctx, list, sizeof(ns_lwsearchlist_t)); isc_mem_detach(&mctx); }
static void shutdown_listener(controllistener_t *listener) { controlconnection_t *conn; controlconnection_t *next; if (!listener->exiting) { char socktext[ISC_SOCKADDR_FORMATSIZE]; ISC_LIST_UNLINK(listener->controls->listeners, listener, link); isc_sockaddr_format(&listener->address, socktext, sizeof(socktext)); isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_CONTROL, ISC_LOG_NOTICE, "stopping command channel on %s", socktext); if (listener->type == isc_sockettype_unix) isc_socket_cleanunix(&listener->address, ISC_TRUE); listener->exiting = ISC_TRUE; } for (conn = ISC_LIST_HEAD(listener->connections); conn != NULL; conn = next) { next = ISC_LIST_NEXT(conn, link); maybe_free_connection(conn); } if (listener->listening) isc_socket_cancel(listener->sock, listener->task, ISC_SOCKCANCEL_ACCEPT); maybe_free_listener(listener); }
/*% * Update a single RR in version 'ver' of 'db' and log the * update in 'diff'. * * Ensures: * \li '*tuple' == NULL. Either the tuple is freed, or its * ownership has been transferred to the diff. */ static isc_result_t do_one_tuple(dns_difftuple_t **tuple, dns_db_t *db, dns_dbversion_t *ver, dns_diff_t *diff) { dns_diff_t temp_diff; isc_result_t result; /* * Create a singleton diff. */ dns_diff_init(diff->mctx, &temp_diff); temp_diff.resign = diff->resign; ISC_LIST_APPEND(temp_diff.tuples, *tuple, link); /* * Apply it to the database. */ result = dns_diff_apply(&temp_diff, db, ver); ISC_LIST_UNLINK(temp_diff.tuples, *tuple, link); if (result != ISC_R_SUCCESS) { dns_difftuple_free(tuple); return (result); } /* * Merge it into the current pending journal entry. */ dns_diff_appendminimal(diff, tuple); /* * Do not clear temp_diff. */ return (ISC_R_SUCCESS); }
static isc_result_t configure_listener(isc_sockaddr_t *address, ns_lwresd_t *lwresd, isc_mem_t *mctx, ns_lwreslistenerlist_t *newlisteners) { ns_lwreslistener_t *listener, *oldlistener = NULL; char socktext[ISC_SOCKADDR_FORMATSIZE]; isc_result_t result; (void)find_listener(address, &oldlistener); listener = NULL; result = listener_create(mctx, lwresd, &listener); if (result != ISC_R_SUCCESS) { isc_sockaddr_format(address, socktext, sizeof(socktext)); isc_log_write(ns_g_lctx, ISC_LOGCATEGORY_GENERAL, NS_LOGMODULE_LWRESD, ISC_LOG_WARNING, "lwres failed to configure %s: %s", socktext, isc_result_totext(result)); return (result); } /* * If there's already a listener, don't rebind the socket. */ if (oldlistener == NULL) { result = listener_bind(listener, address); if (result != ISC_R_SUCCESS) { ns_lwreslistener_detach(&listener); return (ISC_R_SUCCESS); } } else listener_copysock(oldlistener, listener); result = listener_startclients(listener); if (result != ISC_R_SUCCESS) { isc_sockaddr_format(address, socktext, sizeof(socktext)); isc_log_write(ns_g_lctx, ISC_LOGCATEGORY_GENERAL, NS_LOGMODULE_LWRESD, ISC_LOG_WARNING, "lwres: failed to start %s: %s", socktext, isc_result_totext(result)); ns_lwreslistener_detach(&listener); return (ISC_R_SUCCESS); } if (oldlistener != NULL) { /* * Remove the old listener from the old list and shut it down. */ ISC_LIST_UNLINK(listeners, oldlistener, link); listener_shutdown(oldlistener); ns_lwreslistener_detach(&oldlistener); } else { isc_sockaddr_format(address, socktext, sizeof(socktext)); isc_log_write(ns_g_lctx, ISC_LOGCATEGORY_GENERAL, NS_LOGMODULE_LWRESD, ISC_LOG_NOTICE, "lwres listening on %s", socktext); } ISC_LIST_APPEND(*newlisteners, listener, link); return (result); }
static void free_namelist(dns_message_t *msg, dns_namelist_t *namelist) { dns_name_t *name; dns_rdataset_t *set; while (!ISC_LIST_EMPTY(*namelist)) { name = ISC_LIST_HEAD(*namelist); ISC_LIST_UNLINK(*namelist, name, link); while (!ISC_LIST_EMPTY(name->list)) { set = ISC_LIST_HEAD(name->list); ISC_LIST_UNLINK(name->list, set, link); dns_message_puttemprdataset(msg, &set); } dns_message_puttempname(msg, &name); } }
isc_result_t pk11_finalize(void) { pk11_token_t *token, *next; isc_result_t ret; ret = free_all_sessions(); (void) pkcs_C_Finalize(NULL_PTR); token = ISC_LIST_HEAD(tokens); while (token != NULL) { next = ISC_LIST_NEXT(token, link); ISC_LIST_UNLINK(tokens, token, link); if (token == rand_token) rand_token = NULL; if (token == best_rsa_token) best_rsa_token = NULL; if (token == best_dsa_token) best_dsa_token = NULL; if (token == best_dh_token) best_dh_token = NULL; if (token == digest_token) digest_token = NULL; if (token == best_ec_token) best_ec_token = NULL; if (token == best_gost_token) best_gost_token = NULL; if (token == aes_token) aes_token = NULL; pk11_mem_put(token, sizeof(*token)); token = next; } if (pk11_mctx != NULL) isc_mem_detach(&pk11_mctx); initialized = ISC_FALSE; return (ret); }
/* * Do all the crap needed to move a client from the run queue to the idle * queue. */ void ns_lwdclient_stateidle(ns_lwdclient_t *client) { ns_lwdclientmgr_t *cm; isc_result_t result; cm = client->clientmgr; INSIST(client->sendbuf == NULL); INSIST(client->sendlength == 0); INSIST(client->arg == NULL); INSIST(client->v4find == NULL); INSIST(client->v6find == NULL); ISC_LIST_UNLINK(cm->running, client, link); ISC_LIST_PREPEND(cm->idle, client, link); NS_LWDCLIENT_SETIDLE(client); result = ns_lwdclient_startrecv(cm); if (result != ISC_R_SUCCESS) isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_LWRESD, ISC_LOG_ERROR, "could not start lwres " "client handler: %s", isc_result_totext(result)); }
static void peerlist_delete(dns_peerlist_t **list) { dns_peerlist_t *l; dns_peer_t *server, *stmp; REQUIRE(list != NULL); REQUIRE(DNS_PEERLIST_VALID(*list)); l = *list; REQUIRE(l->refs == 0); server = ISC_LIST_HEAD(l->elements); while (server != NULL) { stmp = ISC_LIST_NEXT(server, next); ISC_LIST_UNLINK(l->elements, server, next); dns_peer_detach(&server); server = stmp; } l->magic = 0; isc_mem_put(l->mem, l, sizeof(*l)); *list = NULL; }
static void free_controlkeylist(controlkeylist_t *keylist, isc_mem_t *mctx) { while (!ISC_LIST_EMPTY(*keylist)) { controlkey_t *key = ISC_LIST_HEAD(*keylist); ISC_LIST_UNLINK(*keylist, key, link); free_controlkey(key, mctx); } }
static void remove_fromring(dns_tsigkey_t *tkey) { if (tkey->generated) { ISC_LIST_UNLINK(tkey->ring->lru, tkey, link); tkey->ring->generated--; } (void)dns_rbt_deletename(tkey->ring->keys, &tkey->name, ISC_FALSE); }
static struct srv * next_tuple(void) { struct srv_prio *pe; struct srv *se; uint16_t rnd; unsigned csum = 0; unsigned wsum = 0; pe = ISC_LIST_HEAD(prio_list); if (pe == NULL) return (NULL); for (se = ISC_LIST_HEAD(pe->srv_list); se != NULL; se = ISC_LIST_NEXT(se, link)) { wsum += se->weight; } rnd = random() % (wsum + 1); for (se = ISC_LIST_HEAD(pe->srv_list); se != NULL; se = ISC_LIST_NEXT(se, link)) { csum += se->weight; if (csum >= rnd) { ISC_LIST_UNLINK(pe->srv_list, se, link); break; } } if (se == NULL) { ISC_LIST_UNLINK(prio_list, pe, link); free(pe); return (next_tuple()); } #ifdef DEBUG fprintf(stderr, "rnd=%hu -> prio=%hu weight=%hu port=%hu tname=%s\n", rnd, pe->prio, se->weight, se->port, se->tname); #endif return (se); }
void ns_lwreslistener_unlinkcm(ns_lwreslistener_t *listener, ns_lwdclientmgr_t *cm) { REQUIRE(VALID_LWRESLISTENER(listener)); LOCK(&listener->lock); ISC_LIST_UNLINK(listener->cmgrs, cm, link); UNLOCK(&listener->lock); }
void ns_statschannels_shutdown(ns_server_t *server) { ns_statschannel_t *listener; while ((listener = ISC_LIST_HEAD(server->statschannels)) != NULL) { ISC_LIST_UNLINK(server->statschannels, listener, link); shutdown_listener(listener); } }
static void reset_probe (struct probe_trans *trans) { struct probe_ns *pns; struct server *server; isc_result_t result; REQUIRE (trans->resid == NULL); REQUIRE (trans->reqid == NULL); update_stat (trans); dns_message_reset (trans->qmessage, DNS_MESSAGE_INTENTRENDER); dns_message_reset (trans->rmessage, DNS_MESSAGE_INTENTPARSE); trans->inuse = ISC_FALSE; if (trans->domain != NULL) isc_mem_free (mctx, trans->domain); trans->domain = NULL; if (trans->qname != NULL) dns_fixedname_invalidate (&trans->fixedname); trans->qname = NULL; trans->qlabel = qlabels; trans->qname_found = ISC_FALSE; trans->current_ns = NULL; while ((pns = ISC_LIST_HEAD (trans->nslist)) != NULL) { ISC_LIST_UNLINK (trans->nslist, pns, link); while ((server = ISC_LIST_HEAD (pns->servers)) != NULL) { ISC_LIST_UNLINK (pns->servers, server, link); isc_mem_put (mctx, server, sizeof (*server)); } isc_mem_put (mctx, pns, sizeof (*pns)); } outstanding_probes--; result = probe_domain (trans); if (result == ISC_R_NOMORE && outstanding_probes == 0) isc_app_ctxshutdown (actx); }
static isc_result_t convert_named_acl(const cfg_obj_t *nameobj, const cfg_obj_t *cctx, isc_log_t *lctx, cfg_aclconfctx_t *ctx, isc_mem_t *mctx, unsigned int nest_level, dns_acl_t **target) { isc_result_t result; const cfg_obj_t *cacl = NULL; dns_acl_t *dacl; dns_acl_t loop; const char *aclname = cfg_obj_asstring(nameobj); /* Look for an already-converted version. */ for (dacl = ISC_LIST_HEAD(ctx->named_acl_cache); dacl != NULL; dacl = ISC_LIST_NEXT(dacl, nextincache)) { if (strcasecmp(aclname, dacl->name) == 0) { if (ISC_MAGIC_VALID(dacl, LOOP_MAGIC)) { cfg_obj_log(nameobj, lctx, ISC_LOG_ERROR, "acl loop detected: %s", aclname); return (ISC_R_FAILURE); } dns_acl_attach(dacl, target); return (ISC_R_SUCCESS); } } /* Not yet converted. Convert now. */ result = get_acl_def(cctx, aclname, &cacl); if (result != ISC_R_SUCCESS) { cfg_obj_log(nameobj, lctx, ISC_LOG_WARNING, "undefined ACL '%s'", aclname); return (result); } /* * Add a loop detection element. */ memset(&loop, 0, sizeof(loop)); ISC_LINK_INIT(&loop, nextincache); DE_CONST(aclname, loop.name); loop.magic = LOOP_MAGIC; ISC_LIST_APPEND(ctx->named_acl_cache, &loop, nextincache); result = cfg_acl_fromconfig(cacl, cctx, lctx, ctx, mctx, nest_level, &dacl); ISC_LIST_UNLINK(ctx->named_acl_cache, &loop, nextincache); loop.magic = 0; loop.name = NULL; if (result != ISC_R_SUCCESS) return (result); dacl->name = isc_mem_strdup(dacl->mctx, aclname); if (dacl->name == NULL) return (ISC_R_NOMEMORY); ISC_LIST_APPEND(ctx->named_acl_cache, dacl, nextincache); dns_acl_attach(dacl, target); return (ISC_R_SUCCESS); }
void dns_diff_clear(dns_diff_t *diff) { dns_difftuple_t *t; REQUIRE(DNS_DIFF_VALID(diff)); while ((t = ISC_LIST_HEAD(diff->tuples)) != NULL) { ISC_LIST_UNLINK(diff->tuples, t, link); dns_difftuple_free(&t); } ENSURE(ISC_LIST_EMPTY(diff->tuples)); }
static isc_result_t ns_interface_setup(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr, const char *name, ns_interface_t **ifpret, isc_boolean_t accept_tcp) { isc_result_t result; ns_interface_t *ifp = NULL; REQUIRE(ifpret != NULL && *ifpret == NULL); result = ns_interface_create(mgr, addr, name, &ifp); if (result != ISC_R_SUCCESS) return (result); // added-by-db #ifdef IO_USE_NETMAP printf("%s:%s:%d. IO USE NETMAP.\n", __FILE__,__FUNCTION__,__LINE__); fflush(stdout); if (strncmp(name, "eth1", 4) != 0) { result = ns_interface_listenudp(ifp); } else { printf(" listen netmap on interface:%s\n", name); fflush(stdout); result = ns_interface_listen_netmap(ifp); } #else result = ns_interface_listenudp(ifp); #endif if (result != ISC_R_SUCCESS) goto cleanup_interface; if (accept_tcp == ISC_TRUE) { result = ns_interface_accepttcp(ifp); if (result != ISC_R_SUCCESS) { /* * XXXRTH We don't currently have a way to easily stop * dispatch service, so we currently return * ISC_R_SUCCESS (the UDP stuff will work even if TCP * creation failed). This will be fixed later. */ result = ISC_R_SUCCESS; } } *ifpret = ifp; return (result); cleanup_interface: ISC_LIST_UNLINK(ifp->mgr->interfaces, ifp, link); ns_interface_detach(&ifp); return (result); }
void cleanup_entropy(isc_entropy_t **ectx) { entropysource_t *source; while (!ISC_LIST_EMPTY(sources)) { source = ISC_LIST_HEAD(sources); ISC_LIST_UNLINK(sources, source, link); isc_entropy_destroysource(&source->source); isc_mem_put(source->mctx, source, sizeof(*source)); } isc_entropy_detach(ectx); }
static void clearlistenon(ns_interfacemgr_t *mgr) { isc_sockaddr_t *old; old = ISC_LIST_HEAD(mgr->listenon); while (old != NULL) { ISC_LIST_UNLINK(mgr->listenon, old, link); isc_mem_put(mgr->mctx, old, sizeof(*old)); old = ISC_LIST_HEAD(mgr->listenon); } }
static void httpdmgr_destroy(isc_httpdmgr_t *httpdmgr) { isc_mem_t *mctx; isc_httpdurl_t *url; ENTER("httpdmgr_destroy"); LOCK(&httpdmgr->lock); if (!MSHUTTINGDOWN(httpdmgr)) { NOTICE("httpdmgr_destroy not shutting down yet"); UNLOCK(&httpdmgr->lock); return; } /* * If all clients are not shut down, don't do anything yet. */ if (!ISC_LIST_EMPTY(httpdmgr->running)) { NOTICE("httpdmgr_destroy clients still active"); UNLOCK(&httpdmgr->lock); return; } NOTICE("httpdmgr_destroy detaching socket, task, and timermgr"); isc_socket_detach(&httpdmgr->sock); isc_task_detach(&httpdmgr->task); httpdmgr->timermgr = NULL; /* * Clear out the list of all actions we know about. Just free the * memory. */ url = ISC_LIST_HEAD(httpdmgr->urls); while (url != NULL) { isc_mem_free(httpdmgr->mctx, url->url); ISC_LIST_UNLINK(httpdmgr->urls, url, link); isc_mem_put(httpdmgr->mctx, url, sizeof(isc_httpdurl_t)); url = ISC_LIST_HEAD(httpdmgr->urls); } UNLOCK(&httpdmgr->lock); isc_mutex_destroy(&httpdmgr->lock); if (httpdmgr->ondestroy != NULL) (httpdmgr->ondestroy)(httpdmgr->cb_arg); mctx = httpdmgr->mctx; isc_mem_putanddetach(&mctx, httpdmgr, sizeof(isc_httpdmgr_t)); EXIT("httpdmgr_destroy"); }