]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
rename next,prev to lru_next,lru_prev for clarity.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 26 May 2020 11:41:07 +0000 (13:41 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 26 May 2020 11:41:07 +0000 (13:41 +0200)
services/outside_network.c
services/outside_network.h

index c3350517ddb8ea2512bb04b0a1aaf03ede588885..9b3458922c88bf49b8f52036f34beff0100b64b0 100644 (file)
@@ -484,25 +484,23 @@ reuse_tcp_remove_tree_list(struct outside_network* outnet,
        }
        /* delete from reuse list */
        if(reuse->pending) {
-               if(reuse->prev) {
+               if(reuse->lru_prev) {
                        /* assert that members of the lru list are waiting
                         * and thus have a pending pointer to the struct */
-                       log_assert(reuse->prev->pending);
-                       reuse->prev->next = reuse->next;
+                       log_assert(reuse->lru_prev->pending);
+                       reuse->lru_prev->lru_next = reuse->lru_next;
                } else {
-                       log_assert(!reuse->next || reuse->next->pending);
-                       outnet->tcp_reuse_first =
-                               (reuse->next?reuse->next->pending:NULL);
+                       log_assert(!reuse->lru_next || reuse->lru_next->pending);
+                       outnet->tcp_reuse_first = reuse->lru_next;
                }
-               if(reuse->next) {
+               if(reuse->lru_next) {
                        /* assert that members of the lru list are waiting
                         * and thus have a pending pointer to the struct */
-                       log_assert(reuse->next->pending);
-                       reuse->next->prev = reuse->prev;
+                       log_assert(reuse->lru_next->pending);
+                       reuse->lru_next->lru_prev = reuse->lru_prev;
                } else {
-                       log_assert(!reuse->prev || reuse->prev->pending);
-                       outnet->tcp_reuse_last =
-                               (reuse->prev?reuse->prev->pending:NULL);
+                       log_assert(!reuse->lru_prev || reuse->lru_prev->pending);
+                       outnet->tcp_reuse_last = reuse->lru_prev;
                }
                reuse->pending = NULL;
        }
@@ -544,15 +542,15 @@ reuse_tcp_insert(struct outside_network* outnet, struct pending_tcp* pend_tcp)
                return 0;
        }
        /* insert into LRU, first is newest */
-       pend_tcp->reuse.prev = NULL;
+       pend_tcp->reuse.lru_prev = NULL;
        if(outnet->tcp_reuse_first) {
-               pend_tcp->reuse.next = &outnet->tcp_reuse_first->reuse;
-               outnet->tcp_reuse_first->reuse.prev = &pend_tcp->reuse;
+               pend_tcp->reuse.lru_next = outnet->tcp_reuse_first;
+               outnet->tcp_reuse_first->lru_prev = &pend_tcp->reuse;
        } else {
-               pend_tcp->reuse.next = NULL;
-               outnet->tcp_reuse_last = pend_tcp;
+               pend_tcp->reuse.lru_next = NULL;
+               outnet->tcp_reuse_last = &pend_tcp->reuse;
        }
-       outnet->tcp_reuse_first = pend_tcp;
+       outnet->tcp_reuse_first = &pend_tcp->reuse;
        return 1;
 }
 
@@ -1452,14 +1450,13 @@ reuse_tcp_close_oldest(struct outside_network* outnet)
 {
        struct pending_tcp* pend;
        if(!outnet->tcp_reuse_last) return;
-       pend = outnet->tcp_reuse_last;
+       pend = outnet->tcp_reuse_last->pending;
 
        /* snip off of LRU */
-       log_assert(pend->reuse.next == NULL);
-       if(pend->reuse.prev) {
-               log_assert(pend->reuse.prev->pending);
-               outnet->tcp_reuse_last = pend->reuse.prev->pending;
-               pend->reuse.prev->next = NULL;
+       log_assert(pend->reuse.lru_next == NULL);
+       if(pend->reuse.lru_prev) {
+               outnet->tcp_reuse_last = pend->reuse.lru_prev;
+               pend->reuse.lru_prev->lru_next = NULL;
        } else {
                outnet->tcp_reuse_last = NULL;
                outnet->tcp_reuse_first = NULL;
index 0230829a8705c2d9b27f5146ab94f433deb7294d..f8f62238de9738dfdcd1c10efc38debaaa7f26a5 100644 (file)
@@ -169,7 +169,7 @@ struct outside_network {
         * the oldest can be closed to get a new free pending_tcp if needed
         * The list contains empty connections, that wait for timeout or
         * a new query that can use the existing connection. */
-       struct pending_tcp* tcp_reuse_first, *tcp_reuse_last;
+       struct reuse_tcp* tcp_reuse_first, *tcp_reuse_last;
        /** list of tcp comm points that are free for use */
        struct pending_tcp* tcp_free;
        /** list of tcp queries waiting for a buffer */
@@ -240,10 +240,8 @@ struct reuse_tcp {
         * the ones with active queries are not on the list because they
         * do not need to be closed to make space for others.  They already
         * service a query so the close for another query does not help
-        * service a larger number of queries.
-        * TODO
-        */
-       struct reuse_tcp* next, *prev;
+        * service a larger number of queries. */
+       struct reuse_tcp* lru_next, *lru_prev;
        /** true if the reuse_tcp item is on the lru list with empty items */
        int item_on_lru_list;
        /** the connection to reuse, the fd is non-1 and is open.
@@ -251,18 +249,17 @@ struct reuse_tcp {
         * and is key to the rbtree.  The SSL ptr determines if it is
         * a TLS connection or a plain TCP connection there.  And TLS
         * or not is also part of the key to the rbtree.
-        * There is a timeout and read event on the fd, to close it.
-        */
+        * There is a timeout and read event on the fd, to close it. */
        struct pending_tcp* pending;
        /** rbtree with other queries waiting on the connection, by ID number,
         * of type struct waiting_tcp. It is for looking up received
         * answers to the structure for callback.  And also to see if ID
-        * numbers are unused and can be used for a new query. TODO */
+        * numbers are unused and can be used for a new query. */
        rbtree_type tree_by_id;
        /** list of queries waiting to be written on the channel,
         * if NULL no queries are waiting to be written and the pending->query
         * is the query currently serviced.  The first is the next in line.
-        * Once written, a query moves to the tree_by_id. TODO */
+        * Once written, a query moves to the tree_by_id. */
        struct waiting_tcp* write_wait_first, *write_wait_last;
 };