]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
stream reuse, the id for pending stored in waiting_tcp structure, because
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Thu, 9 Jul 2020 11:58:44 +0000 (13:58 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Thu, 9 Jul 2020 11:58:44 +0000 (13:58 +0200)
there can be multiple messages waiting for reply.

services/outside_network.c
services/outside_network.h

index 5082f5f0385048212f53501b2a71fece2da74d50..07454d3242356488e7f8eac7bbf2823070d058ac 100644 (file)
@@ -172,11 +172,9 @@ int reuse_id_cmp(const void* key1, const void* key2)
 {
        struct waiting_tcp* w1 = (struct waiting_tcp*)key1;
        struct waiting_tcp* w2 = (struct waiting_tcp*)key2;
-       struct pending_tcp* p1 = (struct pending_tcp*)w1->next_waiting;
-       struct pending_tcp* p2 = (struct pending_tcp*)w2->next_waiting;
-       if(p1->id < p2->id)
+       if(w1->id < w2->id)
                return -1;
-       if(p1->id > p2->id)
+       if(w1->id > w2->id)
                return 1;
        return 0;
 }
@@ -420,12 +418,9 @@ static struct waiting_tcp*
 reuse_tcp_by_id_find(struct reuse_tcp* reuse, uint16_t id)
 {
        struct waiting_tcp key_w;
-       struct pending_tcp key_p;
        memset(&key_w, 0, sizeof(key_w));
-       memset(&key_p, 0, sizeof(key_p));
-       key_w.next_waiting = (void*)&key_p;
        key_w.id_node.key = &key_w;
-       key_p.id = id;
+       key_w.id = id;
        return (struct waiting_tcp*)rbtree_search(&reuse->tree_by_id, &key_w);
 }
 
@@ -434,7 +429,7 @@ static uint16_t
 tree_by_id_get_id(rbnode_type* node)
 {
        struct waiting_tcp* w = (struct waiting_tcp*)node->key;
-       return ((struct pending_tcp*)w->next_waiting)->id;
+       return w->id;
 }
 
 /** find reuse tcp stream to destination for query, or NULL if none */
@@ -509,7 +504,7 @@ outnet_tcp_take_query_setup(int s, struct pending_tcp* pend,
        struct waiting_tcp* w)
 {
        struct timeval tv;
-       pend->id = LDNS_ID_WIRE(w->pkt);
+       w->id = LDNS_ID_WIRE(w->pkt);
        pend->c->tcp_write_pkt = w->pkt;
        pend->c->tcp_write_pkt_len = w->pkt_len;
        pend->c->tcp_write_and_read = 1;
index 0dcf1b2e1e75dba4a8a1a22c11e1a10a165a21a1..9ebbabe9cb8d4eef3c9965fca6b8949ce143ccdf 100644 (file)
@@ -324,8 +324,6 @@ struct pending {
 struct pending_tcp {
        /** next in list of free tcp comm points, or NULL. */
        struct pending_tcp* next_free;
-       /** the ID for the query; checked in reply */
-       uint16_t id;
        /** tcp comm point it was sent on (and reply must come back on). */
        struct comm_point* c;
        /** the query being serviced, NULL if the pending_tcp is unused. */
@@ -355,8 +353,10 @@ struct waiting_tcp {
        /** true if the waiting_tcp structure is on the write_wait queue */
        int write_wait_queued;
        /** entry in reuse.tree_by_id, if key is NULL, not in tree, otherwise,
-        * this struct is key and sorted by ID from pending_tcp->id. */
+        * this struct is key and sorted by ID (from waiting_tcp.id). */
        rbnode_type id_node;
+       /** the ID for the query; checked in reply */
+       uint16_t id;
        /** timeout event; timer keeps running whether the query is
         * waiting for a buffer or the tcp reply is pending */
        struct comm_timer* timer;