mirror of
https://gitlab.isc.org/isc-projects/bind9.git
synced 2025-04-18 09:44:09 +03:00
use ISC_LIST_FOREACH in more places
use the ISC_LIST_FOREACH pattern in places where lists had been iterated using a different pattern from the typical `for` loop: for example, `while (!ISC_LIST_EMPTY(...))` or `while ((e = ISC_LIST_HEAD(...)) != NULL)`.
This commit is contained in:
parent
522ca7bb54
commit
ad7f744115
@ -956,10 +956,9 @@ addserver(dns_client_t *client) {
|
||||
CHECK(dns_client_setservers(client, dns_rdataclass_in, name, &servers));
|
||||
|
||||
cleanup:
|
||||
while (!ISC_LIST_EMPTY(servers)) {
|
||||
sa = ISC_LIST_HEAD(servers);
|
||||
ISC_LIST_UNLINK(servers, sa, link);
|
||||
isc_mem_put(mctx, sa, sizeof(*sa));
|
||||
ISC_LIST_FOREACH_SAFE (servers, s, link) {
|
||||
ISC_LIST_UNLINK(servers, s, link);
|
||||
isc_mem_put(mctx, s, sizeof(*s));
|
||||
}
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
@ -501,15 +501,10 @@ get_server_list(irs_resconf_t *resconf) {
|
||||
|
||||
void
|
||||
flush_server_list(void) {
|
||||
dig_server_t *s, *ps;
|
||||
|
||||
debug("flush_server_list()");
|
||||
s = ISC_LIST_HEAD(server_list);
|
||||
while (s != NULL) {
|
||||
ps = s;
|
||||
s = ISC_LIST_NEXT(s, link);
|
||||
ISC_LIST_DEQUEUE(server_list, ps, link);
|
||||
isc_mem_free(mctx, ps);
|
||||
ISC_LIST_FOREACH_SAFE (server_list, s, link) {
|
||||
ISC_LIST_DEQUEUE(server_list, s, link);
|
||||
isc_mem_free(mctx, s);
|
||||
}
|
||||
}
|
||||
|
||||
@ -553,15 +548,12 @@ set_nameserver(char *opt) {
|
||||
*/
|
||||
void
|
||||
clone_server_list(dig_serverlist_t src, dig_serverlist_t *dest) {
|
||||
dig_server_t *srv, *newsrv;
|
||||
|
||||
debug("clone_server_list()");
|
||||
srv = ISC_LIST_HEAD(src);
|
||||
while (srv != NULL) {
|
||||
newsrv = make_server(srv->servername, srv->userarg);
|
||||
ISC_LIST_FOREACH_SAFE (src, srv, link) {
|
||||
dig_server_t *newsrv = make_server(srv->servername,
|
||||
srv->userarg);
|
||||
ISC_LINK_INIT(newsrv, link);
|
||||
ISC_LIST_ENQUEUE(*dest, newsrv, link);
|
||||
srv = ISC_LIST_NEXT(srv, link);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1208,8 +1200,7 @@ make_searchlist_entry(char *domain) {
|
||||
|
||||
static void
|
||||
clear_searchlist(void) {
|
||||
dig_searchlist_t *search;
|
||||
while ((search = ISC_LIST_HEAD(search_list)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (search_list, search, link) {
|
||||
ISC_LIST_UNLINK(search_list, search, link);
|
||||
isc_mem_free(mctx, search);
|
||||
}
|
||||
@ -1496,17 +1487,11 @@ add_question(dns_message_t *message, dns_name_t *name, dns_rdataclass_t rdclass,
|
||||
*/
|
||||
static void
|
||||
check_if_done(void) {
|
||||
dig_lookup_t *lookup = NULL;
|
||||
|
||||
debug("check_if_done()");
|
||||
debug("list %s", ISC_LIST_EMPTY(lookup_list) ? "empty" : "full");
|
||||
|
||||
lookup = ISC_LIST_HEAD(lookup_list);
|
||||
while (lookup != NULL) {
|
||||
dig_lookup_t *next = NULL;
|
||||
ISC_LIST_FOREACH (lookup_list, lookup, link) {
|
||||
debug("pending lookup %p", lookup);
|
||||
next = ISC_LIST_NEXT(lookup, link);
|
||||
lookup = next;
|
||||
}
|
||||
|
||||
if (ISC_LIST_EMPTY(lookup_list) && current_lookup == NULL &&
|
||||
@ -1529,18 +1514,15 @@ check_if_done(void) {
|
||||
*/
|
||||
static bool
|
||||
check_if_queries_done(dig_lookup_t *l, dig_query_t *except_q) {
|
||||
dig_query_t *q = ISC_LIST_HEAD(l->q);
|
||||
|
||||
debug("check_if_queries_done(%p)", l);
|
||||
|
||||
while (q != NULL) {
|
||||
ISC_LIST_FOREACH (l->q, q, link) {
|
||||
if (!q->started || isc_refcount_current(&q->references) > 1) {
|
||||
if (!q->canceled && q != except_q) {
|
||||
debug("there is a pending query %p", q);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
q = ISC_LIST_NEXT(q, link);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1548,9 +1530,6 @@ check_if_queries_done(dig_lookup_t *l, dig_query_t *except_q) {
|
||||
|
||||
static void
|
||||
_destroy_lookup(dig_lookup_t *lookup) {
|
||||
dig_server_t *s;
|
||||
void *ptr;
|
||||
|
||||
REQUIRE(lookup != NULL);
|
||||
REQUIRE(ISC_LIST_EMPTY(lookup->q));
|
||||
|
||||
@ -1558,14 +1537,10 @@ _destroy_lookup(dig_lookup_t *lookup) {
|
||||
|
||||
isc_refcount_destroy(&lookup->references);
|
||||
|
||||
s = ISC_LIST_HEAD(lookup->my_server_list);
|
||||
while (s != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (lookup->my_server_list, s, link) {
|
||||
debug("freeing server %p belonging to %p", s, lookup);
|
||||
ptr = s;
|
||||
s = ISC_LIST_NEXT(s, link);
|
||||
ISC_LIST_DEQUEUE(lookup->my_server_list, (dig_server_t *)ptr,
|
||||
link);
|
||||
isc_mem_free(mctx, ptr);
|
||||
ISC_LIST_DEQUEUE(lookup->my_server_list, s, link);
|
||||
isc_mem_free(mctx, s);
|
||||
}
|
||||
if (lookup->sendmsg != NULL) {
|
||||
dns_message_detach(&lookup->sendmsg);
|
||||
@ -2741,13 +2716,9 @@ send_done(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
|
||||
|
||||
static void
|
||||
_cancel_lookup(dig_lookup_t *lookup, const char *file, unsigned int line) {
|
||||
dig_query_t *query, *next;
|
||||
|
||||
debug("%s:%u:%s()", file, line, __func__);
|
||||
query = ISC_LIST_HEAD(lookup->q);
|
||||
while (query != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (lookup->q, query, link) {
|
||||
REQUIRE(DIG_VALID_QUERY(query));
|
||||
next = ISC_LIST_NEXT(query, link);
|
||||
ISC_LIST_DEQUEUE(lookup->q, query, link);
|
||||
debug("canceling pending query %p, belonging to %p", query,
|
||||
query->lookup);
|
||||
@ -2758,7 +2729,6 @@ _cancel_lookup(dig_lookup_t *lookup, const char *file, unsigned int line) {
|
||||
isc_nm_cancelread(query->readhandle);
|
||||
}
|
||||
query_detach(&query);
|
||||
query = next;
|
||||
}
|
||||
lookup->pending = false;
|
||||
lookup->retries = 0;
|
||||
@ -4658,8 +4628,6 @@ run_loop(void *arg) {
|
||||
*/
|
||||
void
|
||||
cancel_all(void) {
|
||||
dig_lookup_t *l, *n;
|
||||
|
||||
debug("cancel_all()");
|
||||
|
||||
if (free_now) {
|
||||
@ -4688,12 +4656,9 @@ cancel_all(void) {
|
||||
lookup_detach(¤t_lookup);
|
||||
}
|
||||
}
|
||||
l = ISC_LIST_HEAD(lookup_list);
|
||||
while (l != NULL) {
|
||||
n = ISC_LIST_NEXT(l, link);
|
||||
ISC_LIST_FOREACH_SAFE (lookup_list, l, link) {
|
||||
ISC_LIST_DEQUEUE(lookup_list, l, link);
|
||||
lookup_detach(&l);
|
||||
l = n;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,13 +446,10 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg,
|
||||
|
||||
static void
|
||||
show_settings(bool full, bool serv_only) {
|
||||
dig_server_t *srv;
|
||||
isc_sockaddr_t sockaddr;
|
||||
isc_result_t result;
|
||||
|
||||
srv = ISC_LIST_HEAD(server_list);
|
||||
|
||||
while (srv != NULL) {
|
||||
ISC_LIST_FOREACH (server_list, srv, link) {
|
||||
char sockstr[ISC_SOCKADDR_FORMATSIZE];
|
||||
|
||||
result = get_address(srv->servername, port, &sockaddr);
|
||||
@ -464,7 +461,6 @@ show_settings(bool full, bool serv_only) {
|
||||
if (!full) {
|
||||
return;
|
||||
}
|
||||
srv = ISC_LIST_NEXT(srv, link);
|
||||
}
|
||||
if (serv_only) {
|
||||
return;
|
||||
|
@ -236,8 +236,7 @@ get_dnskeys(ksr_ctx_t *ksr, dns_dnsseckeylist_t *keys) {
|
||||
keys_sorted[i++] = dk;
|
||||
}
|
||||
qsort(keys_sorted, n, sizeof(dns_dnsseckey_t *), keyalgtag_cmp);
|
||||
while (!ISC_LIST_EMPTY(keys_read)) {
|
||||
dns_dnsseckey_t *key = ISC_LIST_HEAD(keys_read);
|
||||
ISC_LIST_FOREACH_SAFE (keys_read, key, link) {
|
||||
ISC_LIST_UNLINK(keys_read, key, link);
|
||||
}
|
||||
/* Save sorted list in 'keys' */
|
||||
@ -264,20 +263,16 @@ setcontext(ksr_ctx_t *ksr, dns_kasp_t *kasp) {
|
||||
|
||||
static void
|
||||
cleanup(dns_dnsseckeylist_t *keys, dns_kasp_t *kasp) {
|
||||
while (!ISC_LIST_EMPTY(*keys)) {
|
||||
dns_dnsseckey_t *key = ISC_LIST_HEAD(*keys);
|
||||
ISC_LIST_FOREACH_SAFE (*keys, key, link) {
|
||||
ISC_LIST_UNLINK(*keys, key, link);
|
||||
dst_key_free(&key->key);
|
||||
dns_dnsseckey_destroy(mctx, &key);
|
||||
}
|
||||
dns_kasp_detach(&kasp);
|
||||
|
||||
isc_buffer_t *cbuf = ISC_LIST_HEAD(cleanup_list);
|
||||
while (cbuf != NULL) {
|
||||
isc_buffer_t *nbuf = ISC_LIST_NEXT(cbuf, link);
|
||||
ISC_LIST_FOREACH_SAFE (cleanup_list, cbuf, link) {
|
||||
ISC_LIST_UNLINK(cleanup_list, cbuf, link);
|
||||
isc_buffer_free(&cbuf);
|
||||
cbuf = nbuf;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2725,9 +2725,7 @@ report(const char *format, ...) {
|
||||
|
||||
static void
|
||||
clear_keylist(dns_dnsseckeylist_t *list) {
|
||||
dns_dnsseckey_t *key;
|
||||
while (!ISC_LIST_EMPTY(*list)) {
|
||||
key = ISC_LIST_HEAD(*list);
|
||||
ISC_LIST_FOREACH_SAFE (*list, key, link) {
|
||||
ISC_LIST_UNLINK(*list, key, link);
|
||||
dns_dnsseckey_destroy(mctx, &key);
|
||||
}
|
||||
|
@ -792,19 +792,14 @@ createnode(bdb_t *bdb, bdbnode_t **nodep) {
|
||||
|
||||
static void
|
||||
destroynode(bdbnode_t *node) {
|
||||
dns_rdatalist_t *list = NULL;
|
||||
dns_rdata_t *rdata = NULL;
|
||||
isc_buffer_t *b = NULL;
|
||||
bdb_t *bdb = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
|
||||
bdb = node->bdb;
|
||||
mctx = bdb->common.mctx;
|
||||
|
||||
while (!ISC_LIST_EMPTY(node->lists)) {
|
||||
list = ISC_LIST_HEAD(node->lists);
|
||||
while (!ISC_LIST_EMPTY(list->rdata)) {
|
||||
rdata = ISC_LIST_HEAD(list->rdata);
|
||||
ISC_LIST_FOREACH_SAFE (node->lists, list, link) {
|
||||
ISC_LIST_FOREACH_SAFE (list->rdata, rdata, link) {
|
||||
ISC_LIST_UNLINK(list->rdata, rdata, link);
|
||||
isc_mem_put(mctx, rdata, sizeof(dns_rdata_t));
|
||||
}
|
||||
@ -812,8 +807,7 @@ destroynode(bdbnode_t *node) {
|
||||
isc_mem_put(mctx, list, sizeof(dns_rdatalist_t));
|
||||
}
|
||||
|
||||
while (!ISC_LIST_EMPTY(node->buffers)) {
|
||||
b = ISC_LIST_HEAD(node->buffers);
|
||||
ISC_LIST_FOREACH_SAFE (node->buffers, b, link) {
|
||||
ISC_LIST_UNLINK(node->buffers, b, link);
|
||||
isc_buffer_free(&b);
|
||||
}
|
||||
@ -1107,7 +1101,6 @@ findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
||||
dns_rdataset_t *rdataset,
|
||||
dns_rdataset_t *sigrdataset DNS__DB_FLARG) {
|
||||
bdbnode_t *bdbnode = (bdbnode_t *)node;
|
||||
dns_rdatalist_t *list = NULL;
|
||||
|
||||
REQUIRE(VALID_BDBNODE(bdbnode));
|
||||
|
||||
@ -1120,20 +1113,14 @@ findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
||||
return ISC_R_NOTIMPLEMENTED;
|
||||
}
|
||||
|
||||
list = ISC_LIST_HEAD(bdbnode->lists);
|
||||
while (list != NULL) {
|
||||
ISC_LIST_FOREACH (bdbnode->lists, list, link) {
|
||||
if (list->type == type) {
|
||||
break;
|
||||
new_rdataset(list, db, node, rdataset);
|
||||
return ISC_R_SUCCESS;
|
||||
}
|
||||
list = ISC_LIST_NEXT(list, link);
|
||||
}
|
||||
if (list == NULL) {
|
||||
return ISC_R_NOTFOUND;
|
||||
}
|
||||
|
||||
new_rdataset(list, db, node, rdataset);
|
||||
|
||||
return ISC_R_SUCCESS;
|
||||
return ISC_R_NOTFOUND;
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
|
@ -170,8 +170,7 @@ free_controlkey(controlkey_t *key, isc_mem_t *mctx) {
|
||||
|
||||
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_FOREACH_SAFE (*keylist, key, link) {
|
||||
ISC_LIST_UNLINK(*keylist, key, link);
|
||||
free_controlkey(key, mctx);
|
||||
}
|
||||
|
@ -5966,7 +5966,6 @@ configure_forward(const cfg_obj_t *config, dns_view_t *view,
|
||||
const cfg_listelt_t *element = NULL;
|
||||
dns_fwdpolicy_t fwdpolicy = dns_fwdpolicy_none;
|
||||
dns_forwarderlist_t fwdlist;
|
||||
dns_forwarder_t *fwd = NULL;
|
||||
isc_result_t result;
|
||||
in_port_t port;
|
||||
in_port_t tls_port;
|
||||
@ -6021,7 +6020,8 @@ configure_forward(const cfg_obj_t *config, dns_view_t *view,
|
||||
const cfg_obj_t *forwarder = cfg_listelt_value(element);
|
||||
const char *cur_tls = NULL;
|
||||
|
||||
fwd = isc_mem_get(view->mctx, sizeof(dns_forwarder_t));
|
||||
dns_forwarder_t *fwd = isc_mem_get(view->mctx,
|
||||
sizeof(dns_forwarder_t));
|
||||
fwd->tlsname = NULL;
|
||||
cur_tls = cfg_obj_getsockaddrtls(forwarder);
|
||||
if (cur_tls == NULL) {
|
||||
@ -6086,8 +6086,7 @@ configure_forward(const cfg_obj_t *config, dns_view_t *view,
|
||||
|
||||
cleanup:
|
||||
|
||||
while (!ISC_LIST_EMPTY(fwdlist)) {
|
||||
fwd = ISC_LIST_HEAD(fwdlist);
|
||||
ISC_LIST_FOREACH_SAFE (fwdlist, fwd, link) {
|
||||
ISC_LIST_UNLINK(fwdlist, fwd, link);
|
||||
if (fwd->tlsname != NULL) {
|
||||
dns_name_free(fwd->tlsname, view->mctx);
|
||||
@ -7854,13 +7853,13 @@ load_configuration(const char *filename, named_server_t *server,
|
||||
bool first_time) {
|
||||
cfg_obj_t *config = NULL, *bindkeys = NULL;
|
||||
cfg_parser_t *conf_parser = NULL, *bindkeys_parser = NULL;
|
||||
const cfg_listelt_t *element;
|
||||
const cfg_obj_t *builtin_views;
|
||||
const cfg_listelt_t *element = NULL;
|
||||
const cfg_obj_t *builtin_views = NULL;
|
||||
const cfg_obj_t *maps[3];
|
||||
const cfg_obj_t *obj;
|
||||
const cfg_obj_t *options;
|
||||
const cfg_obj_t *kasps;
|
||||
const cfg_obj_t *keystores;
|
||||
const cfg_obj_t *obj = NULL;
|
||||
const cfg_obj_t *options = NULL;
|
||||
const cfg_obj_t *kasps = NULL;
|
||||
const cfg_obj_t *keystores = NULL;
|
||||
dns_kasp_t *default_kasp = NULL;
|
||||
dns_kasplist_t tmpkasplist, kasplist;
|
||||
dns_keystorelist_t tmpkeystorelist, keystorelist;
|
||||
@ -7881,9 +7880,8 @@ load_configuration(const char *filename, named_server_t *server,
|
||||
uint32_t send_tcp_buffer_size;
|
||||
uint32_t recv_udp_buffer_size;
|
||||
uint32_t send_udp_buffer_size;
|
||||
named_cache_t *nsc = NULL;
|
||||
named_cachelist_t cachelist, tmpcachelist;
|
||||
ns_altsecret_t *altsecret;
|
||||
ns_altsecret_t *altsecret = NULL;
|
||||
ns_altsecretlist_t altsecrets, tmpaltsecrets;
|
||||
uint32_t softquota = 0;
|
||||
uint32_t max;
|
||||
@ -9234,9 +9232,9 @@ load_configuration(const char *filename, named_server_t *server,
|
||||
* were swapped above or not.
|
||||
*/
|
||||
cleanup_altsecrets:
|
||||
while ((altsecret = ISC_LIST_HEAD(altsecrets)) != NULL) {
|
||||
ISC_LIST_UNLINK(altsecrets, altsecret, link);
|
||||
isc_mem_put(server->sctx->mctx, altsecret, sizeof(*altsecret));
|
||||
ISC_LIST_FOREACH_SAFE (altsecrets, as, link) {
|
||||
ISC_LIST_UNLINK(altsecrets, as, link);
|
||||
isc_mem_put(server->sctx->mctx, as, sizeof(*as));
|
||||
}
|
||||
|
||||
cleanup_logc:
|
||||
@ -9245,7 +9243,7 @@ cleanup_logc:
|
||||
}
|
||||
|
||||
cleanup_cachelist:
|
||||
while ((nsc = ISC_LIST_HEAD(cachelist)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (cachelist, nsc, link) {
|
||||
ISC_LIST_UNLINK(cachelist, nsc, link);
|
||||
dns_cache_detach(&nsc->cache);
|
||||
isc_mem_put(server->mctx, nsc, sizeof(*nsc));
|
||||
@ -9505,7 +9503,6 @@ static void
|
||||
shutdown_server(void *arg) {
|
||||
named_server_t *server = (named_server_t *)arg;
|
||||
bool flush = server->flushonshutdown;
|
||||
named_cache_t *nsc = NULL;
|
||||
|
||||
named_os_notify_systemd("STOPPING=1\n");
|
||||
named_os_notify_close();
|
||||
@ -9566,7 +9563,7 @@ shutdown_server(void *arg) {
|
||||
*/
|
||||
dns_dyndb_cleanup();
|
||||
|
||||
while ((nsc = ISC_LIST_HEAD(server->cachelist)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (server->cachelist, nsc, link) {
|
||||
ISC_LIST_UNLINK(server->cachelist, nsc, link);
|
||||
dns_cache_detach(&nsc->cache);
|
||||
isc_mem_put(server->mctx, nsc, sizeof(*nsc));
|
||||
@ -11099,22 +11096,15 @@ add_view_tolist(struct dumpcontext *dctx, dns_view_t *view) {
|
||||
|
||||
static void
|
||||
dumpcontext_destroy(struct dumpcontext *dctx) {
|
||||
struct viewlistentry *vle;
|
||||
struct zonelistentry *zle;
|
||||
|
||||
vle = ISC_LIST_HEAD(dctx->viewlist);
|
||||
while (vle != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (dctx->viewlist, vle, link) {
|
||||
ISC_LIST_UNLINK(dctx->viewlist, vle, link);
|
||||
zle = ISC_LIST_HEAD(vle->zonelist);
|
||||
while (zle != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (vle->zonelist, zle, link) {
|
||||
ISC_LIST_UNLINK(vle->zonelist, zle, link);
|
||||
dns_zone_detach(&zle->zone);
|
||||
isc_mem_put(dctx->mctx, zle, sizeof *zle);
|
||||
zle = ISC_LIST_HEAD(vle->zonelist);
|
||||
}
|
||||
dns_view_detach(&vle->view);
|
||||
isc_mem_put(dctx->mctx, vle, sizeof *vle);
|
||||
vle = ISC_LIST_HEAD(dctx->viewlist);
|
||||
}
|
||||
if (dctx->version != NULL) {
|
||||
dns_db_closeversion(dctx->db, &dctx->version, false);
|
||||
@ -14412,7 +14402,6 @@ named_server_dnssec(named_server_t *server, isc_lex_t *lex,
|
||||
dns_zone_t *zone = NULL;
|
||||
dns_kasp_t *kasp = NULL;
|
||||
dns_dnsseckeylist_t keys;
|
||||
dns_dnsseckey_t *key;
|
||||
char *ptr, *zonetext = NULL;
|
||||
const char *msg = NULL;
|
||||
/* variables for -checkds */
|
||||
@ -14704,8 +14693,7 @@ cleanup:
|
||||
dns_db_detach(&db);
|
||||
}
|
||||
|
||||
while (!ISC_LIST_EMPTY(keys)) {
|
||||
key = ISC_LIST_HEAD(keys);
|
||||
ISC_LIST_FOREACH_SAFE (keys, key, link) {
|
||||
ISC_LIST_UNLINK(keys, key, link);
|
||||
dns_dnsseckey_destroy(dns_zone_getmctx(zone), &key);
|
||||
}
|
||||
|
@ -2813,7 +2813,6 @@ cleanup:
|
||||
static isc_result_t
|
||||
generatejson(named_server_t *server, size_t *msglen, const char **msg,
|
||||
json_object **rootp, uint32_t flags) {
|
||||
dns_view_t *view;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
json_object *bindstats, *viewlist, *counters, *obj;
|
||||
json_object *traffic = NULL;
|
||||
@ -3036,8 +3035,7 @@ generatejson(named_server_t *server, size_t *msglen, const char **msg,
|
||||
|
||||
json_object_object_add(bindstats, "views", viewlist);
|
||||
|
||||
view = ISC_LIST_HEAD(server->viewlist);
|
||||
while (view != NULL) {
|
||||
ISC_LIST_FOREACH (server->viewlist, view, link) {
|
||||
json_object *za, *xa, *v = json_object_new_object();
|
||||
dns_adb_t *adb = NULL;
|
||||
|
||||
@ -3185,8 +3183,6 @@ generatejson(named_server_t *server, size_t *msglen, const char **msg,
|
||||
counters);
|
||||
}
|
||||
}
|
||||
|
||||
view = ISC_LIST_NEXT(view, link);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -566,7 +566,6 @@ configure_staticstub(const cfg_obj_t *zconfig, dns_zone_t *zone,
|
||||
dns_rdatalist_t rdatalist_ns, rdatalist_a, rdatalist_aaaa;
|
||||
dns_rdatalist_t *rdatalists[] = { &rdatalist_ns, &rdatalist_a,
|
||||
&rdatalist_aaaa, NULL };
|
||||
dns_rdata_t *rdata;
|
||||
isc_region_t region;
|
||||
|
||||
/* Create the DB beforehand */
|
||||
@ -678,7 +677,7 @@ cleanup:
|
||||
dns_db_detach(&db);
|
||||
}
|
||||
for (i = 0; rdatalists[i] != NULL; i++) {
|
||||
while ((rdata = ISC_LIST_HEAD(rdatalists[i]->rdata)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (rdatalists[i]->rdata, rdata, link) {
|
||||
ISC_LIST_UNLINK(rdatalists[i]->rdata, rdata, link);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
isc_mem_put(mctx, rdata,
|
||||
|
@ -2085,7 +2085,6 @@ setup(void *arg ISC_ATTR_UNUSED) {
|
||||
/*% Main processing routine for mdig */
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
struct query *query = NULL;
|
||||
isc_result_t result;
|
||||
unsigned int i;
|
||||
int ns;
|
||||
@ -2130,9 +2129,8 @@ main(int argc, char *argv[]) {
|
||||
fatal("can't choose between IPv4 and IPv6");
|
||||
}
|
||||
|
||||
query = ISC_LIST_HEAD(queries);
|
||||
isc_loopmgr_setup(loopmgr, setup, NULL);
|
||||
isc_loopmgr_setup(loopmgr, sendqueries, query);
|
||||
isc_loopmgr_setup(loopmgr, sendqueries, ISC_LIST_HEAD(queries));
|
||||
isc_loopmgr_teardown(loopmgr, teardown, NULL);
|
||||
|
||||
/*
|
||||
@ -2163,10 +2161,7 @@ main(int argc, char *argv[]) {
|
||||
|
||||
isc_loopmgr_run(loopmgr);
|
||||
|
||||
query = ISC_LIST_HEAD(queries);
|
||||
while (query != NULL) {
|
||||
struct query *next = ISC_LIST_NEXT(query, link);
|
||||
|
||||
ISC_LIST_FOREACH_SAFE (queries, query, link) {
|
||||
if (query->ednsopts != NULL) {
|
||||
for (i = 0; i < EDNSOPTS; i++) {
|
||||
if (query->ednsopts[i].value != NULL) {
|
||||
@ -2181,7 +2176,6 @@ main(int argc, char *argv[]) {
|
||||
query->ecs_addr = NULL;
|
||||
}
|
||||
isc_mem_free(mctx, query);
|
||||
query = next;
|
||||
}
|
||||
|
||||
if (default_query.ecs_addr != NULL) {
|
||||
|
@ -762,10 +762,7 @@ shutdown_entries(dns_adb_t *adb) {
|
||||
*/
|
||||
static void
|
||||
clean_namehooks(dns_adb_t *adb, dns_adbnamehooklist_t *namehooks) {
|
||||
dns_adbnamehook_t *namehook = NULL;
|
||||
|
||||
namehook = ISC_LIST_HEAD(*namehooks);
|
||||
while (namehook != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (*namehooks, namehook, name_link) {
|
||||
INSIST(DNS_ADBNAMEHOOK_VALID(namehook));
|
||||
INSIST(DNS_ADBENTRY_VALID(namehook->entry));
|
||||
|
||||
@ -783,8 +780,6 @@ clean_namehooks(dns_adb_t *adb, dns_adbnamehooklist_t *namehooks) {
|
||||
dns_adbentry_detach(&adbentry);
|
||||
|
||||
free_adbnamehook(adb, &namehook);
|
||||
|
||||
namehook = ISC_LIST_HEAD(*namehooks);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1373,12 +1368,10 @@ log_quota(dns_adbentry_t *entry, const char *fmt, ...) {
|
||||
|
||||
static void
|
||||
copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find, dns_adbname_t *name) {
|
||||
dns_adbnamehook_t *namehook = NULL;
|
||||
dns_adbentry_t *entry = NULL;
|
||||
|
||||
if ((find->options & DNS_ADBFIND_INET) != 0) {
|
||||
namehook = ISC_LIST_HEAD(name->v4);
|
||||
while (namehook != NULL) {
|
||||
ISC_LIST_FOREACH (name->v4, namehook, name_link) {
|
||||
dns_adbaddrinfo_t *addrinfo = NULL;
|
||||
entry = namehook->entry;
|
||||
|
||||
@ -1386,7 +1379,7 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find, dns_adbname_t *name) {
|
||||
adbentry_overquota(entry))
|
||||
{
|
||||
find->options |= DNS_ADBFIND_OVERQUOTA;
|
||||
goto nextv4;
|
||||
continue;
|
||||
}
|
||||
|
||||
addrinfo = new_adbaddrinfo(adb, entry, find->port);
|
||||
@ -1395,14 +1388,11 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find, dns_adbname_t *name) {
|
||||
* Found a valid entry. Add it to the find's list.
|
||||
*/
|
||||
ISC_LIST_APPEND(find->list, addrinfo, publink);
|
||||
nextv4:
|
||||
namehook = ISC_LIST_NEXT(namehook, name_link);
|
||||
}
|
||||
}
|
||||
|
||||
if ((find->options & DNS_ADBFIND_INET6) != 0) {
|
||||
namehook = ISC_LIST_HEAD(name->v6);
|
||||
while (namehook != NULL) {
|
||||
ISC_LIST_FOREACH (name->v6, namehook, name_link) {
|
||||
dns_adbaddrinfo_t *addrinfo = NULL;
|
||||
entry = namehook->entry;
|
||||
|
||||
@ -1410,7 +1400,7 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find, dns_adbname_t *name) {
|
||||
adbentry_overquota(entry))
|
||||
{
|
||||
find->options |= DNS_ADBFIND_OVERQUOTA;
|
||||
goto nextv6;
|
||||
continue;
|
||||
}
|
||||
|
||||
addrinfo = new_adbaddrinfo(adb, entry, find->port);
|
||||
@ -1419,8 +1409,6 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find, dns_adbname_t *name) {
|
||||
* Found a valid entry. Add it to the find's list.
|
||||
*/
|
||||
ISC_LIST_APPEND(find->list, addrinfo, publink);
|
||||
nextv6:
|
||||
namehook = ISC_LIST_NEXT(namehook, name_link);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2134,7 +2122,6 @@ post_copy:
|
||||
void
|
||||
dns_adb_destroyfind(dns_adbfind_t **findp) {
|
||||
dns_adbfind_t *find = NULL;
|
||||
dns_adbaddrinfo_t *ai = NULL;
|
||||
dns_adb_t *adb = NULL;
|
||||
|
||||
REQUIRE(findp != NULL && DNS_ADBFIND_VALID(*findp));
|
||||
@ -2155,11 +2142,9 @@ dns_adb_destroyfind(dns_adbfind_t **findp) {
|
||||
* we also need to decrement the reference counter in the
|
||||
* associated adbentry every time we remove one from the list.
|
||||
*/
|
||||
ai = ISC_LIST_HEAD(find->list);
|
||||
while (ai != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (find->list, ai, publink) {
|
||||
ISC_LIST_UNLINK(find->list, ai, publink);
|
||||
free_adbaddrinfo(adb, &ai);
|
||||
ai = ISC_LIST_HEAD(find->list);
|
||||
}
|
||||
UNLOCK(&find->lock);
|
||||
|
||||
@ -2367,7 +2352,6 @@ static void
|
||||
dumpfind(dns_adbfind_t *find, FILE *f) {
|
||||
char tmp[512];
|
||||
const char *tmpp = NULL;
|
||||
dns_adbaddrinfo_t *ai = NULL;
|
||||
isc_sockaddr_t *sa = NULL;
|
||||
|
||||
/*
|
||||
@ -2383,11 +2367,10 @@ dumpfind(dns_adbfind_t *find, FILE *f) {
|
||||
find->flags);
|
||||
fprintf(f, ";\tname %p\n", find->adbname);
|
||||
|
||||
ai = ISC_LIST_HEAD(find->list);
|
||||
if (ai != NULL) {
|
||||
if (!ISC_LIST_EMPTY(find->list)) {
|
||||
fprintf(f, "\tAddresses:\n");
|
||||
}
|
||||
while (ai != NULL) {
|
||||
ISC_LIST_FOREACH (find->list, ai, publink) {
|
||||
sa = &ai->sockaddr;
|
||||
switch (sa->type.sa.sa_family) {
|
||||
case AF_INET:
|
||||
@ -2410,8 +2393,6 @@ dumpfind(dns_adbfind_t *find, FILE *f) {
|
||||
"\t\tentry %p, flags %08x"
|
||||
" srtt %u addr %s\n",
|
||||
ai->entry, ai->flags, ai->srtt, tmpp);
|
||||
|
||||
ai = ISC_LIST_NEXT(ai, publink);
|
||||
}
|
||||
|
||||
UNLOCK(&find->lock);
|
||||
@ -2448,12 +2429,8 @@ print_fetch_list(FILE *f, dns_adbname_t *n) {
|
||||
|
||||
static void
|
||||
print_find_list(FILE *f, dns_adbname_t *name) {
|
||||
dns_adbfind_t *find = NULL;
|
||||
|
||||
find = ISC_LIST_HEAD(name->finds);
|
||||
while (find != NULL) {
|
||||
ISC_LIST_FOREACH (name->finds, find, plink) {
|
||||
dumpfind(find, f);
|
||||
find = ISC_LIST_NEXT(find, plink);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -771,11 +771,7 @@ client_resfind(resctx_t *rctx, dns_fetchresponse_t *resp) {
|
||||
* Free temporary resources
|
||||
*/
|
||||
if (ansname != NULL) {
|
||||
dns_rdataset_t *rdataset;
|
||||
|
||||
while ((rdataset = ISC_LIST_HEAD(ansname->list)) !=
|
||||
NULL)
|
||||
{
|
||||
ISC_LIST_FOREACH_SAFE (ansname->list, rdataset, link) {
|
||||
ISC_LIST_UNLINK(ansname->list, rdataset, link);
|
||||
putrdataset(mctx, &rdataset);
|
||||
}
|
||||
|
@ -129,9 +129,8 @@ dns_diff_init(isc_mem_t *mctx, dns_diff_t *diff) {
|
||||
|
||||
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_FOREACH_SAFE (diff->tuples, t, link) {
|
||||
ISC_LIST_UNLINK(diff->tuples, t, link);
|
||||
dns_difftuple_free(&t);
|
||||
}
|
||||
|
@ -1416,14 +1416,12 @@ addkey(dns_dnsseckeylist_t *keylist, dst_key_t **newkey, bool savekeys,
|
||||
dns_dnsseckey_t *key = NULL;
|
||||
|
||||
/* Skip duplicates */
|
||||
for (key = ISC_LIST_HEAD(*keylist); key != NULL;
|
||||
key = ISC_LIST_NEXT(key, link))
|
||||
{
|
||||
if (dst_key_id(key->key) == dst_key_id(*newkey) &&
|
||||
dst_key_alg(key->key) == dst_key_alg(*newkey) &&
|
||||
dns_name_equal(dst_key_name(key->key),
|
||||
dst_key_name(*newkey)))
|
||||
ISC_LIST_FOREACH (*keylist, k, link) {
|
||||
if (dst_key_id(k->key) == dst_key_id(*newkey) &&
|
||||
dst_key_alg(k->key) == dst_key_alg(*newkey) &&
|
||||
dns_name_equal(dst_key_name(k->key), dst_key_name(*newkey)))
|
||||
{
|
||||
key = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2189,23 +2187,21 @@ dns_dnssec_updatekeys(dns_dnsseckeylist_t *keys, dns_dnsseckeylist_t *newkeys,
|
||||
char keystr2[DST_KEY_FORMATSIZE];
|
||||
dns_dnsseckey_t *key2 = NULL;
|
||||
|
||||
for (key2 = ISC_LIST_HEAD(*keys); key2 != NULL;
|
||||
key2 = ISC_LIST_NEXT(key2, link))
|
||||
{
|
||||
ISC_LIST_FOREACH (*keys, k2, link) {
|
||||
int f1 = dst_key_flags(key1->key);
|
||||
int f2 = dst_key_flags(key2->key);
|
||||
int f2 = dst_key_flags(k2->key);
|
||||
int nr1 = f1 & ~DNS_KEYFLAG_REVOKE;
|
||||
int nr2 = f2 & ~DNS_KEYFLAG_REVOKE;
|
||||
if (nr1 == nr2 &&
|
||||
dst_key_alg(key1->key) == dst_key_alg(key2->key) &&
|
||||
dst_key_pubcompare(key1->key, key2->key, true))
|
||||
dst_key_alg(key1->key) == dst_key_alg(k2->key) &&
|
||||
dst_key_pubcompare(key1->key, k2->key, true))
|
||||
{
|
||||
int r1, r2;
|
||||
r1 = dst_key_flags(key1->key) &
|
||||
DNS_KEYFLAG_REVOKE;
|
||||
r2 = dst_key_flags(key2->key) &
|
||||
DNS_KEYFLAG_REVOKE;
|
||||
int r1 = dst_key_flags(key1->key) &
|
||||
DNS_KEYFLAG_REVOKE;
|
||||
int r2 = dst_key_flags(k2->key) &
|
||||
DNS_KEYFLAG_REVOKE;
|
||||
key_revoked = (r1 != r2);
|
||||
key2 = k2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -195,10 +195,7 @@ dns_fwdtable_destroy(dns_fwdtable_t **fwdtablep) {
|
||||
|
||||
static void
|
||||
destroy_forwarders(dns_forwarders_t *forwarders) {
|
||||
dns_forwarder_t *fwd = NULL;
|
||||
|
||||
while (!ISC_LIST_EMPTY(forwarders->fwdrs)) {
|
||||
fwd = ISC_LIST_HEAD(forwarders->fwdrs);
|
||||
ISC_LIST_FOREACH_SAFE (forwarders->fwdrs, fwd, link) {
|
||||
ISC_LIST_UNLINK(forwarders->fwdrs, fwd, link);
|
||||
if (fwd->tlsname != NULL) {
|
||||
dns_name_free(fwd->tlsname, forwarders->mctx);
|
||||
|
@ -2041,7 +2041,6 @@ dns_keymgr_run(const dns_name_t *origin, dns_rdataclass_t rdclass,
|
||||
dns_kasp_t *kasp, isc_stdtime_t now, isc_stdtime_t *nexttime) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
dns_dnsseckeylist_t newkeys;
|
||||
dns_dnsseckey_t *newkey = NULL;
|
||||
bool secure_to_insecure = false;
|
||||
int numkeys = 0;
|
||||
int options = (DST_TYPE_PRIVATE | DST_TYPE_PUBLIC | DST_TYPE_STATE);
|
||||
@ -2269,7 +2268,7 @@ dns_keymgr_run(const dns_name_t *origin, dns_rdataclass_t rdclass,
|
||||
|
||||
failure:
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
while ((newkey = ISC_LIST_HEAD(newkeys)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (newkeys, newkey, link) {
|
||||
ISC_LIST_UNLINK(newkeys, newkey, link);
|
||||
INSIST(newkey->key != NULL);
|
||||
dst_key_free(&newkey->key);
|
||||
|
@ -1015,7 +1015,6 @@ load_text(dns_loadctx_t *lctx) {
|
||||
isc_result_t result = ISC_R_UNEXPECTED;
|
||||
rdatalist_head_t glue_list;
|
||||
rdatalist_head_t current_list;
|
||||
dns_rdatalist_t *this = NULL;
|
||||
dns_rdatalist_t *rdatalist = NULL;
|
||||
dns_rdatalist_t *new_rdatalist = NULL;
|
||||
int rdlcount = 0;
|
||||
@ -1082,6 +1081,8 @@ load_text(dns_loadctx_t *lctx) {
|
||||
}
|
||||
source = isc_lex_getsourcename(lctx->lex);
|
||||
while (true) {
|
||||
dns_rdatalist_t *this = NULL;
|
||||
|
||||
if (atomic_load_acquire(&lctx->canceled)) {
|
||||
result = ISC_R_CANCELED;
|
||||
goto log_and_cleanup;
|
||||
@ -2115,10 +2116,10 @@ cleanup:
|
||||
callbacks->commit(callbacks->add_private);
|
||||
}
|
||||
|
||||
while ((this = ISC_LIST_HEAD(current_list)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (current_list, this, link) {
|
||||
ISC_LIST_UNLINK(current_list, this, link);
|
||||
}
|
||||
while ((this = ISC_LIST_HEAD(glue_list)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (glue_list, this, link) {
|
||||
ISC_LIST_UNLINK(glue_list, this, link);
|
||||
}
|
||||
if (rdatalist != NULL) {
|
||||
@ -2752,16 +2753,15 @@ grow_rdatalist(int new_len, dns_rdatalist_t *oldlist, int old_len,
|
||||
dns_rdatalist_t *newlist;
|
||||
int rdlcount = 0;
|
||||
ISC_LIST(dns_rdatalist_t) save;
|
||||
dns_rdatalist_t *this;
|
||||
|
||||
newlist = isc_mem_cget(mctx, new_len, sizeof(newlist[0]));
|
||||
|
||||
ISC_LIST_INIT(save);
|
||||
while ((this = ISC_LIST_HEAD(*current)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (*current, this, link) {
|
||||
ISC_LIST_UNLINK(*current, this, link);
|
||||
ISC_LIST_APPEND(save, this, link);
|
||||
}
|
||||
while ((this = ISC_LIST_HEAD(save)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (save, this, link) {
|
||||
ISC_LIST_UNLINK(save, this, link);
|
||||
INSIST(rdlcount < new_len);
|
||||
newlist[rdlcount] = *this;
|
||||
@ -2770,11 +2770,11 @@ grow_rdatalist(int new_len, dns_rdatalist_t *oldlist, int old_len,
|
||||
}
|
||||
|
||||
ISC_LIST_INIT(save);
|
||||
while ((this = ISC_LIST_HEAD(*glue)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (*glue, this, link) {
|
||||
ISC_LIST_UNLINK(*glue, this, link);
|
||||
ISC_LIST_APPEND(save, this, link);
|
||||
}
|
||||
while ((this = ISC_LIST_HEAD(save)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (save, this, link) {
|
||||
ISC_LIST_UNLINK(save, this, link);
|
||||
INSIST(rdlcount < new_len);
|
||||
newlist[rdlcount] = *this;
|
||||
@ -2799,49 +2799,43 @@ grow_rdata(int new_len, dns_rdata_t *oldlist, int old_len,
|
||||
dns_rdata_t *newlist;
|
||||
int rdcount = 0;
|
||||
ISC_LIST(dns_rdata_t) save;
|
||||
dns_rdatalist_t *this;
|
||||
dns_rdata_t *rdata;
|
||||
|
||||
newlist = isc_mem_cget(mctx, new_len, sizeof(*newlist));
|
||||
|
||||
/*
|
||||
* Copy current relinking.
|
||||
*/
|
||||
this = ISC_LIST_HEAD(*current);
|
||||
while (this != NULL) {
|
||||
ISC_LIST_FOREACH (*current, this, link) {
|
||||
ISC_LIST_INIT(save);
|
||||
while ((rdata = ISC_LIST_HEAD(this->rdata)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (this->rdata, rdata, link) {
|
||||
ISC_LIST_UNLINK(this->rdata, rdata, link);
|
||||
ISC_LIST_APPEND(save, rdata, link);
|
||||
}
|
||||
while ((rdata = ISC_LIST_HEAD(save)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (save, rdata, link) {
|
||||
ISC_LIST_UNLINK(save, rdata, link);
|
||||
INSIST(rdcount < new_len);
|
||||
newlist[rdcount] = *rdata;
|
||||
ISC_LIST_APPEND(this->rdata, &newlist[rdcount], link);
|
||||
rdcount++;
|
||||
}
|
||||
this = ISC_LIST_NEXT(this, link);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy glue relinking.
|
||||
*/
|
||||
this = ISC_LIST_HEAD(*glue);
|
||||
while (this != NULL) {
|
||||
ISC_LIST_FOREACH (*glue, this, link) {
|
||||
ISC_LIST_INIT(save);
|
||||
while ((rdata = ISC_LIST_HEAD(this->rdata)) != NULL) {
|
||||
ISC_LIST_FOREACH (this->rdata, rdata, link) {
|
||||
ISC_LIST_UNLINK(this->rdata, rdata, link);
|
||||
ISC_LIST_APPEND(save, rdata, link);
|
||||
}
|
||||
while ((rdata = ISC_LIST_HEAD(save)) != NULL) {
|
||||
ISC_LIST_FOREACH (save, rdata, link) {
|
||||
ISC_LIST_UNLINK(save, rdata, link);
|
||||
INSIST(rdcount < new_len);
|
||||
newlist[rdcount] = *rdata;
|
||||
ISC_LIST_APPEND(this->rdata, &newlist[rdcount], link);
|
||||
rdcount++;
|
||||
}
|
||||
this = ISC_LIST_NEXT(this, link);
|
||||
}
|
||||
INSIST(rdcount == old_len || rdcount == 0);
|
||||
if (oldlist != NULL) {
|
||||
@ -2887,16 +2881,14 @@ static isc_result_t
|
||||
commit(dns_rdatacallbacks_t *callbacks, dns_loadctx_t *lctx,
|
||||
rdatalist_head_t *head, dns_name_t *owner, const char *source,
|
||||
unsigned int line) {
|
||||
dns_rdatalist_t *this;
|
||||
dns_rdataset_t dataset;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
void (*error)(struct dns_rdatacallbacks *, const char *, ...);
|
||||
|
||||
this = ISC_LIST_HEAD(*head);
|
||||
error = callbacks->error;
|
||||
|
||||
while (this != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (*head, this, link) {
|
||||
dns_rdataset_init(&dataset);
|
||||
dns_rdatalist_tordataset(this, &dataset);
|
||||
dataset.trust = dns_trust_ultimate;
|
||||
@ -2929,7 +2921,6 @@ commit(dns_rdatacallbacks_t *callbacks, dns_loadctx_t *lctx,
|
||||
break;
|
||||
}
|
||||
ISC_LIST_UNLINK(*head, this, link);
|
||||
this = ISC_LIST_HEAD(*head);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -2941,34 +2932,30 @@ commit(dns_rdatacallbacks_t *callbacks, dns_loadctx_t *lctx,
|
||||
|
||||
static bool
|
||||
is_glue(rdatalist_head_t *head, dns_name_t *owner) {
|
||||
dns_rdatalist_t *this;
|
||||
dns_rdata_t *rdata;
|
||||
dns_rdatalist_t *nslist = NULL;
|
||||
isc_region_t region;
|
||||
dns_name_t name;
|
||||
|
||||
/*
|
||||
* Find NS rrset.
|
||||
*/
|
||||
this = ISC_LIST_HEAD(*head);
|
||||
while (this != NULL) {
|
||||
ISC_LIST_FOREACH (*head, this, link) {
|
||||
if (this->type == dns_rdatatype_ns) {
|
||||
nslist = this;
|
||||
break;
|
||||
}
|
||||
this = ISC_LIST_NEXT(this, link);
|
||||
}
|
||||
if (this == NULL) {
|
||||
if (nslist == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
rdata = ISC_LIST_HEAD(this->rdata);
|
||||
while (rdata != NULL) {
|
||||
ISC_LIST_FOREACH (nslist->rdata, rdata, link) {
|
||||
dns_name_init(&name);
|
||||
dns_rdata_toregion(rdata, ®ion);
|
||||
dns_name_fromregion(&name, ®ion);
|
||||
if (dns_name_equal(&name, owner)) {
|
||||
return true;
|
||||
}
|
||||
rdata = ISC_LIST_NEXT(rdata, link);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -516,8 +516,6 @@ static void
|
||||
msgreset(dns_message_t *msg, bool everything) {
|
||||
dns_msgblock_t *msgblock = NULL, *next_msgblock = NULL;
|
||||
isc_buffer_t *dynbuf = NULL, *next_dynbuf = NULL;
|
||||
dns_rdata_t *rdata = NULL;
|
||||
dns_rdatalist_t *rdatalist = NULL;
|
||||
|
||||
msgresetnames(msg, 0);
|
||||
msgresetopt(msg);
|
||||
@ -532,15 +530,11 @@ msgreset(dns_message_t *msg, bool everything) {
|
||||
* The memory isn't lost since these are part of message blocks we
|
||||
* have allocated.
|
||||
*/
|
||||
rdata = ISC_LIST_HEAD(msg->freerdata);
|
||||
while (rdata != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (msg->freerdata, rdata, link) {
|
||||
ISC_LIST_UNLINK(msg->freerdata, rdata, link);
|
||||
rdata = ISC_LIST_HEAD(msg->freerdata);
|
||||
}
|
||||
rdatalist = ISC_LIST_HEAD(msg->freerdatalist);
|
||||
while (rdatalist != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (msg->freerdatalist, rdatalist, link) {
|
||||
ISC_LIST_UNLINK(msg->freerdatalist, rdatalist, link);
|
||||
rdatalist = ISC_LIST_HEAD(msg->freerdatalist);
|
||||
}
|
||||
|
||||
dynbuf = ISC_LIST_HEAD(msg->scratchpad);
|
||||
|
@ -285,11 +285,7 @@ dns_nsec_nseconly(dns_db_t *db, dns_dbversion_t *version, dns_diff_t *diff,
|
||||
{
|
||||
bool deleted = false;
|
||||
if (diff != NULL) {
|
||||
for (dns_difftuple_t *tuple =
|
||||
ISC_LIST_HEAD(diff->tuples);
|
||||
tuple != NULL;
|
||||
tuple = ISC_LIST_NEXT(tuple, link))
|
||||
{
|
||||
ISC_LIST_FOREACH (diff->tuples, tuple, link) {
|
||||
if (tuple->rdata.type !=
|
||||
dns_rdatatype_dnskey ||
|
||||
tuple->op != DNS_DIFFOP_DEL)
|
||||
|
@ -129,15 +129,13 @@ dns_order_attach(dns_order_t *source, dns_order_t **target) {
|
||||
void
|
||||
dns_order_detach(dns_order_t **orderp) {
|
||||
REQUIRE(orderp != NULL && DNS_ORDER_VALID(*orderp));
|
||||
dns_order_t *order;
|
||||
order = *orderp;
|
||||
dns_order_t *order = *orderp;
|
||||
*orderp = NULL;
|
||||
|
||||
if (isc_refcount_decrement(&order->references) == 1) {
|
||||
isc_refcount_destroy(&order->references);
|
||||
order->magic = 0;
|
||||
dns_order_ent_t *ent;
|
||||
while ((ent = ISC_LIST_HEAD(order->ents)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (order->ents, ent, link) {
|
||||
ISC_LIST_UNLINK(order->ents, ent, link);
|
||||
isc_mem_put(order->mctx, ent, sizeof(*ent));
|
||||
}
|
||||
|
@ -157,8 +157,7 @@ dns_peerlist_detach(dns_peerlist_t **list) {
|
||||
|
||||
static void
|
||||
peerlist_delete(dns_peerlist_t **list) {
|
||||
dns_peerlist_t *l;
|
||||
dns_peer_t *server, *stmp;
|
||||
dns_peerlist_t *l = NULL;
|
||||
|
||||
REQUIRE(list != NULL);
|
||||
REQUIRE(DNS_PEERLIST_VALID(*list));
|
||||
@ -168,12 +167,9 @@ peerlist_delete(dns_peerlist_t **list) {
|
||||
|
||||
isc_refcount_destroy(&l->refs);
|
||||
|
||||
server = ISC_LIST_HEAD(l->elements);
|
||||
while (server != NULL) {
|
||||
stmp = ISC_LIST_NEXT(server, next);
|
||||
ISC_LIST_FOREACH_SAFE (l->elements, server, next) {
|
||||
ISC_LIST_UNLINK(l->elements, server, next);
|
||||
dns_peer_detach(&server);
|
||||
server = stmp;
|
||||
}
|
||||
|
||||
l->magic = 0;
|
||||
@ -199,31 +195,19 @@ dns_peerlist_addpeer(dns_peerlist_t *peers, dns_peer_t *peer) {
|
||||
isc_result_t
|
||||
dns_peerlist_peerbyaddr(dns_peerlist_t *servers, const isc_netaddr_t *addr,
|
||||
dns_peer_t **retval) {
|
||||
dns_peer_t *server;
|
||||
isc_result_t res;
|
||||
|
||||
REQUIRE(retval != NULL);
|
||||
REQUIRE(DNS_PEERLIST_VALID(servers));
|
||||
|
||||
server = ISC_LIST_HEAD(servers->elements);
|
||||
while (server != NULL) {
|
||||
ISC_LIST_FOREACH (servers->elements, server, next) {
|
||||
if (isc_netaddr_eqprefix(addr, &server->address,
|
||||
server->prefixlen))
|
||||
{
|
||||
break;
|
||||
*retval = server;
|
||||
return ISC_R_SUCCESS;
|
||||
}
|
||||
|
||||
server = ISC_LIST_NEXT(server, next);
|
||||
}
|
||||
|
||||
if (server != NULL) {
|
||||
*retval = server;
|
||||
res = ISC_R_SUCCESS;
|
||||
} else {
|
||||
res = ISC_R_NOTFOUND;
|
||||
}
|
||||
|
||||
return res;
|
||||
return ISC_R_NOTFOUND;
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
|
@ -348,9 +348,7 @@ resconf_parsedomain(irs_resconf_t *conf, FILE *fp) {
|
||||
|
||||
static void
|
||||
free_search(irs_resconf_t *conf) {
|
||||
irs_resconf_search_t *searchentry;
|
||||
|
||||
while ((searchentry = ISC_LIST_HEAD(conf->searchlist)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (conf->searchlist, searchentry, link) {
|
||||
ISC_LIST_UNLINK(conf->searchlist, searchentry, link);
|
||||
isc_mem_free(conf->mctx, searchentry->domain);
|
||||
isc_mem_put(conf->mctx, searchentry, sizeof(*searchentry));
|
||||
@ -636,8 +634,7 @@ error:
|
||||
|
||||
void
|
||||
irs_resconf_destroy(irs_resconf_t **confp) {
|
||||
irs_resconf_t *conf;
|
||||
isc_sockaddr_t *address;
|
||||
irs_resconf_t *conf = NULL;
|
||||
|
||||
REQUIRE(confp != NULL);
|
||||
conf = *confp;
|
||||
@ -646,7 +643,7 @@ irs_resconf_destroy(irs_resconf_t **confp) {
|
||||
|
||||
free_search(conf);
|
||||
|
||||
while ((address = ISC_LIST_HEAD(conf->nameservers)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (conf->nameservers, address, link) {
|
||||
ISC_LIST_UNLINK(conf->nameservers, address, link);
|
||||
isc_mem_put(conf->mctx, address, sizeof(*address));
|
||||
}
|
||||
|
@ -509,9 +509,8 @@ get_entry(dns_rrl_t *rrl, const isc_sockaddr_t *client_addr, dns_zone_t *zone,
|
||||
bool create, char *log_buf, unsigned int log_buf_len) {
|
||||
dns_rrl_key_t key;
|
||||
uint32_t hval;
|
||||
dns_rrl_entry_t *e;
|
||||
dns_rrl_hash_t *hash;
|
||||
dns_rrl_bin_t *new_bin, *old_bin;
|
||||
dns_rrl_hash_t *hash = NULL;
|
||||
dns_rrl_bin_t *new_bin = NULL, *old_bin = NULL;
|
||||
int probes, age;
|
||||
|
||||
make_key(rrl, &key, client_addr, zone, qtype, qname, qclass, rtype);
|
||||
@ -522,14 +521,12 @@ get_entry(dns_rrl_t *rrl, const isc_sockaddr_t *client_addr, dns_zone_t *zone,
|
||||
*/
|
||||
new_bin = get_bin(rrl->hash, hval);
|
||||
probes = 1;
|
||||
e = ISC_LIST_HEAD(*new_bin);
|
||||
while (e != NULL) {
|
||||
ISC_LIST_FOREACH (*new_bin, e, hlink) {
|
||||
if (key_cmp(&e->key, &key)) {
|
||||
ref_entry(rrl, e, probes, now);
|
||||
return e;
|
||||
}
|
||||
++probes;
|
||||
e = ISC_LIST_NEXT(e, hlink);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -537,8 +534,7 @@ get_entry(dns_rrl_t *rrl, const isc_sockaddr_t *client_addr, dns_zone_t *zone,
|
||||
*/
|
||||
if (rrl->old_hash != NULL) {
|
||||
old_bin = get_bin(rrl->old_hash, hval);
|
||||
e = ISC_LIST_HEAD(*old_bin);
|
||||
while (e != NULL) {
|
||||
ISC_LIST_FOREACH (*old_bin, e, hlink) {
|
||||
if (key_cmp(&e->key, &key)) {
|
||||
ISC_LIST_UNLINK(*old_bin, e, hlink);
|
||||
ISC_LIST_PREPEND(*new_bin, e, hlink);
|
||||
@ -546,7 +542,6 @@ get_entry(dns_rrl_t *rrl, const isc_sockaddr_t *client_addr, dns_zone_t *zone,
|
||||
ref_entry(rrl, e, probes, now);
|
||||
return e;
|
||||
}
|
||||
e = ISC_LIST_NEXT(e, hlink);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -568,42 +563,44 @@ get_entry(dns_rrl_t *rrl, const isc_sockaddr_t *client_addr, dns_zone_t *zone,
|
||||
* Try to make more entries if none are idle.
|
||||
* Steal the oldest entry if we cannot create more.
|
||||
*/
|
||||
for (e = ISC_LIST_TAIL(rrl->lru); e != NULL; e = ISC_LIST_PREV(e, lru))
|
||||
{
|
||||
dns_rrl_entry_t *entry = NULL;
|
||||
ISC_LIST_FOREACH_REV (rrl->lru, e, lru) {
|
||||
entry = e;
|
||||
if (!ISC_LINK_LINKED(e, hlink)) {
|
||||
break;
|
||||
}
|
||||
age = get_age(rrl, e, now);
|
||||
if (age <= 1) {
|
||||
e = NULL;
|
||||
entry = NULL;
|
||||
break;
|
||||
}
|
||||
if (!e->logged && response_balance(rrl, e, age) > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (e == NULL) {
|
||||
|
||||
if (entry == NULL) {
|
||||
expand_entries(rrl, ISC_MIN((rrl->num_entries + 1) / 2, 1000));
|
||||
e = ISC_LIST_TAIL(rrl->lru);
|
||||
entry = ISC_LIST_TAIL(rrl->lru);
|
||||
}
|
||||
if (e->logged) {
|
||||
log_end(rrl, e, true, log_buf, log_buf_len);
|
||||
if (entry->logged) {
|
||||
log_end(rrl, entry, true, log_buf, log_buf_len);
|
||||
}
|
||||
if (ISC_LINK_LINKED(e, hlink)) {
|
||||
if (e->hash_gen == rrl->hash_gen) {
|
||||
if (ISC_LINK_LINKED(entry, hlink)) {
|
||||
if (entry->hash_gen == rrl->hash_gen) {
|
||||
hash = rrl->hash;
|
||||
} else {
|
||||
hash = rrl->old_hash;
|
||||
}
|
||||
old_bin = get_bin(hash, hash_key(&e->key));
|
||||
ISC_LIST_UNLINK(*old_bin, e, hlink);
|
||||
old_bin = get_bin(hash, hash_key(&entry->key));
|
||||
ISC_LIST_UNLINK(*old_bin, entry, hlink);
|
||||
}
|
||||
ISC_LIST_PREPEND(*new_bin, e, hlink);
|
||||
e->hash_gen = rrl->hash_gen;
|
||||
e->key = key;
|
||||
e->ts_valid = false;
|
||||
ref_entry(rrl, e, probes, now);
|
||||
return e;
|
||||
ISC_LIST_PREPEND(*new_bin, entry, hlink);
|
||||
entry->hash_gen = rrl->hash_gen;
|
||||
entry->key = key;
|
||||
entry->ts_valid = false;
|
||||
ref_entry(rrl, entry, probes, now);
|
||||
return entry;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1252,9 +1249,8 @@ dns_rrl(dns_view_t *view, dns_zone_t *zone, const isc_sockaddr_t *client_addr,
|
||||
|
||||
void
|
||||
dns_rrl_view_destroy(dns_view_t *view) {
|
||||
dns_rrl_t *rrl;
|
||||
dns_rrl_block_t *b;
|
||||
dns_rrl_hash_t *h;
|
||||
dns_rrl_t *rrl = NULL;
|
||||
dns_rrl_hash_t *h = NULL;
|
||||
char log_buf[DNS_RRL_LOG_BUF_LEN];
|
||||
int i;
|
||||
|
||||
@ -1285,8 +1281,7 @@ dns_rrl_view_destroy(dns_view_t *view) {
|
||||
|
||||
isc_mutex_destroy(&rrl->lock);
|
||||
|
||||
while (!ISC_LIST_EMPTY(rrl->blocks)) {
|
||||
b = ISC_LIST_HEAD(rrl->blocks);
|
||||
ISC_LIST_FOREACH_SAFE (rrl->blocks, b, link) {
|
||||
ISC_LIST_UNLINK(rrl->blocks, b, link);
|
||||
isc_mem_put(rrl->mctx, b, b->size);
|
||||
}
|
||||
|
@ -82,8 +82,7 @@ destroy(dns_ssutable_t *table) {
|
||||
REQUIRE(VALID_SSUTABLE(table));
|
||||
|
||||
mctx = table->mctx;
|
||||
while (!ISC_LIST_EMPTY(table->rules)) {
|
||||
dns_ssurule_t *rule = ISC_LIST_HEAD(table->rules);
|
||||
ISC_LIST_FOREACH_SAFE (table->rules, rule, link) {
|
||||
if (rule->identity != NULL) {
|
||||
dns_name_free(rule->identity, mctx);
|
||||
isc_mem_put(mctx, rule->identity,
|
||||
|
@ -810,21 +810,17 @@ name_order(const void *av, const void *bv) {
|
||||
static isc_result_t
|
||||
uniqify_name_list(dns_diff_t *list) {
|
||||
isc_result_t result;
|
||||
dns_difftuple_t *p, *q;
|
||||
|
||||
CHECK(dns_diff_sort(list, name_order));
|
||||
|
||||
p = ISC_LIST_HEAD(list->tuples);
|
||||
while (p != NULL) {
|
||||
do {
|
||||
q = ISC_LIST_NEXT(p, link);
|
||||
if (q == NULL || !dns_name_equal(&p->name, &q->name)) {
|
||||
break;
|
||||
}
|
||||
ISC_LIST_UNLINK(list->tuples, q, link);
|
||||
dns_difftuple_free(&q);
|
||||
} while (1);
|
||||
p = ISC_LIST_NEXT(p, link);
|
||||
dns_name_t *curr_name = NULL;
|
||||
ISC_LIST_FOREACH_SAFE (list->tuples, p, link) {
|
||||
if (curr_name == NULL || !dns_name_equal(curr_name, &p->name)) {
|
||||
curr_name = &(p->name);
|
||||
} else {
|
||||
ISC_LIST_UNLINK(list->tuples, p, link);
|
||||
dns_difftuple_free(&p);
|
||||
}
|
||||
}
|
||||
failure:
|
||||
return result;
|
||||
@ -1044,7 +1040,6 @@ static isc_result_t
|
||||
find_zone_keys(dns_zone_t *zone, isc_mem_t *mctx, unsigned int maxkeys,
|
||||
dst_key_t **keys, unsigned int *nkeys) {
|
||||
dns_dnsseckeylist_t keylist;
|
||||
dns_dnsseckey_t *k = NULL;
|
||||
unsigned int count = 0;
|
||||
isc_result_t result;
|
||||
isc_stdtime_t now = isc_stdtime_now();
|
||||
@ -1070,10 +1065,12 @@ find_zone_keys(dns_zone_t *zone, isc_mem_t *mctx, unsigned int maxkeys,
|
||||
}
|
||||
|
||||
/* Add new 'dnskeys' to 'keys' */
|
||||
while ((k = ISC_LIST_HEAD(keylist)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (keylist, k, link) {
|
||||
if (count >= maxkeys) {
|
||||
ISC_LIST_UNLINK(keylist, k, link);
|
||||
dns_dnsseckey_destroy(mctx, &k);
|
||||
result = ISC_R_NOSPACE;
|
||||
goto next;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Detect inactive keys */
|
||||
@ -1085,7 +1082,6 @@ find_zone_keys(dns_zone_t *zone, isc_mem_t *mctx, unsigned int maxkeys,
|
||||
k->key = NULL;
|
||||
count++;
|
||||
|
||||
next:
|
||||
ISC_LIST_UNLINK(keylist, k, link);
|
||||
dns_dnsseckey_destroy(mctx, &k);
|
||||
}
|
||||
|
@ -1199,9 +1199,7 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid) {
|
||||
|
||||
static void
|
||||
clear_keylist(dns_dnsseckeylist_t *list, isc_mem_t *mctx) {
|
||||
dns_dnsseckey_t *key;
|
||||
while (!ISC_LIST_EMPTY(*list)) {
|
||||
key = ISC_LIST_HEAD(*list);
|
||||
ISC_LIST_FOREACH_SAFE (*list, key, link) {
|
||||
ISC_LIST_UNLINK(*list, key, link);
|
||||
dns_dnsseckey_destroy(mctx, &key);
|
||||
}
|
||||
@ -4881,8 +4879,7 @@ zone_unchanged(dns_db_t *db1, dns_db_t *db2, isc_mem_t *mctx) {
|
||||
|
||||
static void
|
||||
process_zone_setnsec3param(dns_zone_t *zone) {
|
||||
struct np3 *npe = NULL;
|
||||
while ((npe = ISC_LIST_HEAD(zone->setnsec3param_queue)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (zone->setnsec3param_queue, npe, link) {
|
||||
ISC_LIST_UNLINK(zone->setnsec3param_queue, npe, link);
|
||||
zone_iattach(zone, &npe->zone);
|
||||
isc_async_run(zone->loop, setnsec3param, npe);
|
||||
@ -6648,8 +6645,7 @@ failure:
|
||||
if (node != NULL) {
|
||||
dns_db_detachnode(db, &node);
|
||||
}
|
||||
while (!ISC_LIST_EMPTY(dnskeys)) {
|
||||
dns_dnsseckey_t *key = ISC_LIST_HEAD(dnskeys);
|
||||
ISC_LIST_FOREACH_SAFE (dnskeys, key, link) {
|
||||
ISC_LIST_UNLINK(dnskeys, key, link);
|
||||
dns_dnsseckey_destroy(dns_zone_getmctx(zone), &key);
|
||||
}
|
||||
@ -16455,7 +16451,6 @@ cds_inuse(dns_zone_t *zone, dns_rdata_t *rdata, dns_dnsseckeylist_t *keylist,
|
||||
isc_result_t
|
||||
dns_zone_dnskey_inuse(dns_zone_t *zone, dns_rdata_t *rdata, bool *inuse) {
|
||||
dns_dnsseckeylist_t keylist;
|
||||
dns_dnsseckey_t *key = NULL;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_stdtime_t now = isc_stdtime_now();
|
||||
isc_mem_t *mctx;
|
||||
@ -16505,8 +16500,7 @@ dns_zone_dnskey_inuse(dns_zone_t *zone, dns_rdata_t *rdata, bool *inuse) {
|
||||
break;
|
||||
}
|
||||
|
||||
while (!ISC_LIST_EMPTY(keylist)) {
|
||||
key = ISC_LIST_HEAD(keylist);
|
||||
ISC_LIST_FOREACH_SAFE (keylist, key, link) {
|
||||
ISC_LIST_UNLINK(keylist, key, link);
|
||||
dns_dnsseckey_destroy(mctx, &key);
|
||||
}
|
||||
@ -22129,8 +22123,7 @@ zone_apply_skrbundle(dns_zone_t *zone, dns_skrbundle_t *bundle,
|
||||
remove_rdataset(zone, diff, cdnskeyset);
|
||||
|
||||
/* Add the records from the bundle. */
|
||||
dns_difftuple_t *tuple = ISC_LIST_HEAD(bundle->diff.tuples);
|
||||
while (tuple != NULL) {
|
||||
ISC_LIST_FOREACH (bundle->diff.tuples, tuple, link) {
|
||||
switch (tuple->rdata.type) {
|
||||
case dns_rdatatype_dnskey:
|
||||
add_tuple(diff, tuple);
|
||||
@ -22145,8 +22138,6 @@ zone_apply_skrbundle(dns_zone_t *zone, dns_skrbundle_t *bundle,
|
||||
default:
|
||||
INSIST(0);
|
||||
}
|
||||
|
||||
tuple = ISC_LIST_NEXT(tuple, link);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,10 +392,9 @@ isc_logconfig_set(isc_logconfig_t *lcfg) {
|
||||
|
||||
void
|
||||
isc_logconfig_destroy(isc_logconfig_t **lcfgp) {
|
||||
isc_logconfig_t *lcfg;
|
||||
isc_mem_t *mctx;
|
||||
isc_logchannel_t *channel;
|
||||
char *filename;
|
||||
isc_logconfig_t *lcfg = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
char *filename = NULL;
|
||||
|
||||
REQUIRE(lcfgp != NULL && VALID_CONFIG(*lcfgp));
|
||||
|
||||
@ -414,9 +413,7 @@ isc_logconfig_destroy(isc_logconfig_t **lcfgp) {
|
||||
|
||||
mctx = lcfg->lctx->mctx;
|
||||
|
||||
while ((channel = ISC_LIST_HEAD(lcfg->channels)) != NULL) {
|
||||
ISC_LIST_UNLINK(lcfg->channels, channel, link);
|
||||
|
||||
ISC_LIST_FOREACH_SAFE (lcfg->channels, channel, link) {
|
||||
if (channel->type == ISC_LOG_TOFILE) {
|
||||
/*
|
||||
* The filename for the channel may have ultimately
|
||||
@ -647,11 +644,7 @@ isc_log_setdebuglevel(unsigned int level) {
|
||||
isc_logconfig_t *lcfg = rcu_dereference(isc__lctx->logconfig);
|
||||
if (lcfg != NULL) {
|
||||
LOCK(&isc__lctx->lock);
|
||||
for (isc_logchannel_t *channel =
|
||||
ISC_LIST_HEAD(lcfg->channels);
|
||||
channel != NULL;
|
||||
channel = ISC_LIST_NEXT(channel, link))
|
||||
{
|
||||
ISC_LIST_FOREACH (lcfg->channels, channel, link) {
|
||||
if (channel->type == ISC_LOG_TOFILE &&
|
||||
(channel->flags & ISC_LOG_DEBUGONLY) != 0 &&
|
||||
FILE_STREAM(channel) != NULL)
|
||||
|
@ -248,7 +248,6 @@ unlock:
|
||||
|
||||
static void
|
||||
delete_trace_entry(isc_mem_t *mctx, const void *ptr, size_t size FLARG) {
|
||||
debuglink_t *dl = NULL;
|
||||
uint32_t hash;
|
||||
uint32_t idx;
|
||||
|
||||
@ -275,14 +274,12 @@ delete_trace_entry(isc_mem_t *mctx, const void *ptr, size_t size FLARG) {
|
||||
#endif
|
||||
idx = hash % DEBUG_TABLE_COUNT;
|
||||
|
||||
dl = ISC_LIST_HEAD(mctx->debuglist[idx]);
|
||||
while (dl != NULL) {
|
||||
ISC_LIST_FOREACH (mctx->debuglist[idx], dl, link) {
|
||||
if (dl->ptr == ptr) {
|
||||
ISC_LIST_UNLINK(mctx->debuglist[idx], dl, link);
|
||||
sdallocx(dl, dl->dlsize, mctx->jemalloc_flags);
|
||||
goto unlock;
|
||||
}
|
||||
dl = ISC_LIST_NEXT(dl, link);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -619,7 +616,6 @@ isc__mem_put(isc_mem_t *ctx, void *ptr, size_t size, int flags FLARG) {
|
||||
static void
|
||||
print_active(isc_mem_t *mctx, FILE *out) {
|
||||
if (mctx->debuglist != NULL) {
|
||||
debuglink_t *dl;
|
||||
unsigned int i;
|
||||
bool found;
|
||||
|
||||
@ -627,13 +623,8 @@ print_active(isc_mem_t *mctx, FILE *out) {
|
||||
"allocations:\n");
|
||||
found = false;
|
||||
for (i = 0; i < DEBUG_TABLE_COUNT; i++) {
|
||||
dl = ISC_LIST_HEAD(mctx->debuglist[i]);
|
||||
|
||||
if (dl != NULL) {
|
||||
ISC_LIST_FOREACH (mctx->debuglist[i], dl, link) {
|
||||
found = true;
|
||||
}
|
||||
|
||||
while (dl != NULL) {
|
||||
if (dl->ptr != NULL) {
|
||||
fprintf(out,
|
||||
"\tptr %p size %zu "
|
||||
@ -642,7 +633,6 @@ print_active(isc_mem_t *mctx, FILE *out) {
|
||||
dl->ptr, dl->size, dl->file,
|
||||
dl->line);
|
||||
}
|
||||
dl = ISC_LIST_NEXT(dl, link);
|
||||
}
|
||||
}
|
||||
|
||||
@ -658,8 +648,6 @@ print_active(isc_mem_t *mctx, FILE *out) {
|
||||
*/
|
||||
void
|
||||
isc_mem_stats(isc_mem_t *ctx, FILE *out) {
|
||||
isc_mempool_t *pool = NULL;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
|
||||
MCTXLOCK(ctx);
|
||||
@ -671,20 +659,18 @@ isc_mem_stats(isc_mem_t *ctx, FILE *out) {
|
||||
* isc_mem_t's lock, however, so walking this list and
|
||||
* extracting integers from stats fields is always safe.
|
||||
*/
|
||||
pool = ISC_LIST_HEAD(ctx->pools);
|
||||
if (pool != NULL) {
|
||||
if (!ISC_LIST_EMPTY(ctx->pools)) {
|
||||
fprintf(out, "[Pool statistics]\n");
|
||||
fprintf(out, "%15s %10s %10s %10s %10s %10s %10s %1s\n", "name",
|
||||
"size", "allocated", "freecount", "freemax",
|
||||
"fillcount", "gets", "L");
|
||||
}
|
||||
while (pool != NULL) {
|
||||
ISC_LIST_FOREACH (ctx->pools, pool, link) {
|
||||
fprintf(out,
|
||||
"%15s %10zu %10zu %10zu %10zu %10zu %10zu %10zu %s\n",
|
||||
pool->name, pool->size, (size_t)0, pool->allocated,
|
||||
pool->freecount, pool->freemax, pool->fillcount,
|
||||
pool->gets, "N");
|
||||
pool = ISC_LIST_NEXT(pool, link);
|
||||
}
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
|
@ -1311,12 +1311,9 @@ done:
|
||||
static void
|
||||
call_pending_callbacks(isc__nm_http_pending_callbacks_t pending_callbacks,
|
||||
isc_result_t result) {
|
||||
isc__nm_uvreq_t *cbreq = ISC_LIST_HEAD(pending_callbacks);
|
||||
while (cbreq != NULL) {
|
||||
isc__nm_uvreq_t *next = ISC_LIST_NEXT(cbreq, link);
|
||||
ISC_LIST_FOREACH_SAFE (pending_callbacks, cbreq, link) {
|
||||
ISC_LIST_UNLINK(pending_callbacks, cbreq, link);
|
||||
isc__nm_sendcb(cbreq->handle->sock, cbreq, result, true);
|
||||
cbreq = next;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3041,7 +3038,6 @@ void
|
||||
isc_nm_http_endpoints_detach(isc_nm_http_endpoints_t **restrict epsp) {
|
||||
isc_nm_http_endpoints_t *restrict eps;
|
||||
isc_mem_t *mctx;
|
||||
isc_nm_httphandler_t *handler = NULL;
|
||||
|
||||
REQUIRE(epsp != NULL);
|
||||
eps = *epsp;
|
||||
@ -3055,16 +3051,11 @@ isc_nm_http_endpoints_detach(isc_nm_http_endpoints_t **restrict epsp) {
|
||||
mctx = eps->mctx;
|
||||
|
||||
/* Delete all handlers */
|
||||
handler = ISC_LIST_HEAD(eps->handlers);
|
||||
while (handler != NULL) {
|
||||
isc_nm_httphandler_t *next = NULL;
|
||||
|
||||
next = ISC_LIST_NEXT(handler, link);
|
||||
ISC_LIST_FOREACH_SAFE (eps->handlers, handler, link) {
|
||||
ISC_LIST_DEQUEUE(eps->handlers, handler, link);
|
||||
isc_mem_free(mctx, handler->path);
|
||||
handler->magic = 0;
|
||||
isc_mem_put(mctx, handler, sizeof(*handler));
|
||||
handler = next;
|
||||
}
|
||||
|
||||
eps->magic = 0;
|
||||
@ -3224,15 +3215,10 @@ failed_httpstream_read_cb(isc_nmsocket_t *sock, isc_result_t result,
|
||||
static void
|
||||
client_call_failed_read_cb(isc_result_t result,
|
||||
isc_nm_http_session_t *session) {
|
||||
http_cstream_t *cstream = NULL;
|
||||
|
||||
REQUIRE(VALID_HTTP2_SESSION(session));
|
||||
REQUIRE(result != ISC_R_SUCCESS);
|
||||
|
||||
cstream = ISC_LIST_HEAD(session->cstreams);
|
||||
while (cstream != NULL) {
|
||||
http_cstream_t *next = ISC_LIST_NEXT(cstream, link);
|
||||
|
||||
ISC_LIST_FOREACH_SAFE (session->cstreams, cstream, link) {
|
||||
/*
|
||||
* read_cb could be NULL if cstream was allocated and added
|
||||
* to the tracking list, but was not properly initialized due
|
||||
@ -3253,8 +3239,6 @@ client_call_failed_read_cb(isc_result_t result,
|
||||
ISC_LIST_DEQUEUE(session->cstreams, cstream, link);
|
||||
put_http_cstream(session->mctx, cstream);
|
||||
}
|
||||
|
||||
cstream = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,6 @@ nmsocket_cleanup(void *arg) {
|
||||
REQUIRE(VALID_NMSOCK(sock));
|
||||
REQUIRE(!isc__nmsocket_active(sock));
|
||||
|
||||
isc_nmhandle_t *handle = NULL;
|
||||
isc__networker_t *worker = sock->worker;
|
||||
|
||||
isc_refcount_destroy(&sock->references);
|
||||
@ -467,7 +466,7 @@ nmsocket_cleanup(void *arg) {
|
||||
isc__nmsocket_detach(&sock->outer);
|
||||
}
|
||||
|
||||
while ((handle = ISC_LIST_HEAD(sock->inactive_handles)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (sock->inactive_handles, handle, inactive_link) {
|
||||
ISC_LIST_DEQUEUE(sock->inactive_handles, handle, inactive_link);
|
||||
nmhandle_free(sock, handle);
|
||||
}
|
||||
|
@ -218,7 +218,6 @@ isc_ratelimiter_dequeue(isc_ratelimiter_t *restrict rl, isc_rlevent_t **rlep) {
|
||||
static void
|
||||
isc__ratelimiter_tick(void *arg) {
|
||||
isc_ratelimiter_t *rl = (isc_ratelimiter_t *)arg;
|
||||
isc_rlevent_t *rle = NULL;
|
||||
uint32_t pertic;
|
||||
ISC_LIST(isc_rlevent_t) pending;
|
||||
|
||||
@ -237,7 +236,7 @@ isc__ratelimiter_tick(void *arg) {
|
||||
|
||||
pertic = rl->pertic;
|
||||
while (pertic != 0) {
|
||||
rle = ISC_LIST_HEAD(rl->pending);
|
||||
isc_rlevent_t *rle = ISC_LIST_HEAD(rl->pending);
|
||||
if (rle != NULL) {
|
||||
/* There is work to do. Let's do it after unlocking. */
|
||||
ISC_LIST_UNLINK(rl->pending, rle, link);
|
||||
@ -263,7 +262,7 @@ isc__ratelimiter_tick(void *arg) {
|
||||
unlock:
|
||||
UNLOCK(&rl->lock);
|
||||
|
||||
while ((rle = ISC_LIST_HEAD(pending)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (pending, rle, link) {
|
||||
ISC_LIST_UNLINK(pending, rle, link);
|
||||
isc_async_run(rle->loop, rle->cb, rle->arg);
|
||||
}
|
||||
@ -288,7 +287,6 @@ isc__ratelimiter_doshutdown(void *arg) {
|
||||
|
||||
void
|
||||
isc_ratelimiter_shutdown(isc_ratelimiter_t *restrict rl) {
|
||||
isc_rlevent_t *rle = NULL;
|
||||
ISC_LIST(isc_rlevent_t) pending;
|
||||
|
||||
REQUIRE(VALID_RATELIMITER(rl));
|
||||
@ -304,7 +302,7 @@ isc_ratelimiter_shutdown(isc_ratelimiter_t *restrict rl) {
|
||||
}
|
||||
UNLOCK(&rl->lock);
|
||||
|
||||
while ((rle = ISC_LIST_HEAD(pending)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (pending, rle, link) {
|
||||
ISC_LIST_UNLINK(pending, rle, link);
|
||||
rle->canceled = true;
|
||||
isc_async_run(rl->loop, rle->cb, rle->arg);
|
||||
|
@ -1338,7 +1338,6 @@ void
|
||||
isc_tlsctx_client_session_cache_detach(
|
||||
isc_tlsctx_client_session_cache_t **cachep) {
|
||||
isc_tlsctx_client_session_cache_t *cache = NULL;
|
||||
client_session_cache_entry_t *entry = NULL, *next = NULL;
|
||||
|
||||
REQUIRE(cachep != NULL);
|
||||
|
||||
@ -1355,11 +1354,8 @@ isc_tlsctx_client_session_cache_detach(
|
||||
|
||||
isc_refcount_destroy(&cache->references);
|
||||
|
||||
entry = ISC_LIST_HEAD(cache->lru_entries);
|
||||
while (entry != NULL) {
|
||||
next = ISC_LIST_NEXT(entry, cache_link);
|
||||
ISC_LIST_FOREACH_SAFE (cache->lru_entries, entry, cache_link) {
|
||||
client_cache_entry_delete(cache, entry);
|
||||
entry = next;
|
||||
}
|
||||
|
||||
RUNTIME_CHECK(isc_ht_count(cache->buckets) == 0);
|
||||
|
@ -2883,7 +2883,6 @@ ns_client_dumpmessage(ns_client_t *client, const char *reason) {
|
||||
|
||||
void
|
||||
ns_client_dumprecursing(FILE *f, ns_clientmgr_t *manager) {
|
||||
ns_client_t *client;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
char original[DNS_NAME_FORMATSIZE];
|
||||
char peerbuf[ISC_SOCKADDR_FORMATSIZE];
|
||||
@ -2897,8 +2896,7 @@ ns_client_dumprecursing(FILE *f, ns_clientmgr_t *manager) {
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
|
||||
LOCK(&manager->reclock);
|
||||
client = ISC_LIST_HEAD(manager->recursing);
|
||||
while (client != NULL) {
|
||||
ISC_LIST_FOREACH (manager->recursing, client, rlink) {
|
||||
INSIST(client->state == NS_CLIENTSTATE_RECURSING);
|
||||
|
||||
ns_client_name(client, peerbuf, sizeof(peerbuf));
|
||||
@ -2948,7 +2946,6 @@ ns_client_dumprecursing(FILE *f, ns_clientmgr_t *manager) {
|
||||
sep, name, client->message->id, namebuf, typebuf,
|
||||
classbuf, origfor, original,
|
||||
isc_time_seconds(&client->requesttime));
|
||||
client = ISC_LIST_NEXT(client, rlink);
|
||||
}
|
||||
UNLOCK(&manager->reclock);
|
||||
}
|
||||
|
@ -914,20 +914,15 @@ unlock:
|
||||
|
||||
static void
|
||||
clearlistenon(ns_interfacemgr_t *mgr) {
|
||||
ISC_LIST(isc_sockaddr_t) listenon;
|
||||
isc_sockaddr_t *old;
|
||||
|
||||
ISC_LIST_INIT(listenon);
|
||||
ISC_LIST(isc_sockaddr_t) listenon = ISC_LIST_INITIALIZER;
|
||||
|
||||
LOCK(&mgr->lock);
|
||||
ISC_LIST_MOVE(listenon, mgr->listenon);
|
||||
UNLOCK(&mgr->lock);
|
||||
|
||||
old = ISC_LIST_HEAD(listenon);
|
||||
while (old != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (listenon, old, link) {
|
||||
ISC_LIST_UNLINK(listenon, old, link);
|
||||
isc_mem_put(mgr->mctx, old, sizeof(*old));
|
||||
old = ISC_LIST_HEAD(listenon);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6013,25 +6013,20 @@ cleanup:
|
||||
static void
|
||||
message_clearrdataset(dns_message_t *msg, unsigned int attr) {
|
||||
unsigned int i;
|
||||
dns_rdataset_t *rds, *next_rds;
|
||||
|
||||
/*
|
||||
* Clean up name lists by calling the rdataset disassociate function.
|
||||
*/
|
||||
for (i = DNS_SECTION_ANSWER; i < DNS_SECTION_MAX; i++) {
|
||||
ISC_LIST_FOREACH_SAFE (msg->sections[i], name, link) {
|
||||
rds = ISC_LIST_HEAD(name->list);
|
||||
while (rds != NULL) {
|
||||
next_rds = ISC_LIST_NEXT(rds, link);
|
||||
ISC_LIST_FOREACH_SAFE (name->list, rds, link) {
|
||||
if ((rds->attributes & attr) != attr) {
|
||||
rds = next_rds;
|
||||
continue;
|
||||
}
|
||||
ISC_LIST_UNLINK(name->list, rds, link);
|
||||
INSIST(dns_rdataset_isassociated(rds));
|
||||
dns_rdataset_disassociate(rds);
|
||||
isc_mempool_put(msg->rdspool, rds);
|
||||
rds = next_rds;
|
||||
}
|
||||
|
||||
if (ISC_LIST_EMPTY(name->list)) {
|
||||
|
@ -127,10 +127,7 @@ ns_server_detach(ns_server_t **sctxp) {
|
||||
*sctxp = NULL;
|
||||
|
||||
if (isc_refcount_decrement(&sctx->references) == 1) {
|
||||
ns_altsecret_t *altsecret;
|
||||
isc_quota_t *http_quota;
|
||||
|
||||
while ((altsecret = ISC_LIST_HEAD(sctx->altsecrets)) != NULL) {
|
||||
ISC_LIST_FOREACH_SAFE (sctx->altsecrets, altsecret, link) {
|
||||
ISC_LIST_UNLINK(sctx->altsecrets, altsecret, link);
|
||||
isc_mem_put(sctx->mctx, altsecret, sizeof(*altsecret));
|
||||
}
|
||||
@ -145,16 +142,11 @@ ns_server_detach(ns_server_t **sctxp) {
|
||||
isc_quota_destroy(&sctx->tcpquota);
|
||||
isc_quota_destroy(&sctx->xfroutquota);
|
||||
|
||||
http_quota = ISC_LIST_HEAD(sctx->http_quotas);
|
||||
while (http_quota != NULL) {
|
||||
isc_quota_t *next = NULL;
|
||||
|
||||
next = ISC_LIST_NEXT(http_quota, link);
|
||||
ISC_LIST_FOREACH_SAFE (sctx->http_quotas, http_quota, link) {
|
||||
ISC_LIST_DEQUEUE(sctx->http_quotas, http_quota, link);
|
||||
isc_quota_destroy(http_quota);
|
||||
isc_mem_put(sctx->mctx, http_quota,
|
||||
sizeof(*http_quota));
|
||||
http_quota = next;
|
||||
}
|
||||
isc_mutex_destroy(&sctx->http_quotas_lock);
|
||||
|
||||
|
@ -484,8 +484,7 @@ static isc_result_t
|
||||
do_diff(dns_diff_t *updates, dns_db_t *db, dns_dbversion_t *ver,
|
||||
dns_diff_t *diff) {
|
||||
isc_result_t result;
|
||||
while (!ISC_LIST_EMPTY(updates->tuples)) {
|
||||
dns_difftuple_t *t = ISC_LIST_HEAD(updates->tuples);
|
||||
ISC_LIST_FOREACH_SAFE (updates->tuples, t, link) {
|
||||
ISC_LIST_UNLINK(updates->tuples, t, link);
|
||||
CHECK(do_one_tuple(&t, db, ver, diff));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user