{
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;
}
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);
}
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 */
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;
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. */
/** 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;