unbound: reuse_tcp Struct Reference

unbound 0.1

Data Fields
reuse_tcp Struct Reference

Reuse TCP connection, still open can be used again. More...

`#include <outside_network.h>`

## Data Fields
rbnode_type | node
| rbtree node with links in tcp_reuse tree.
struct sockaddr_storage | addr
| the key for the tcp_reuse tree.
socklen_t | addrlen
| length of addr
int | is_ssl
| also key for tcp_reuse tree, if ssl is used
char * | tls_auth_name
| If is_ssl is enabled, tls_auth_name is part of the key for tcp_reuse tree.
struct reuse_tcp * | lru_next
| lru chain, so that the oldest can be removed to get a new connection when all are in (re)use.
struct reuse_tcp * | lru_prev
int | item_on_lru_list
| true if the reuse_tcp item is on the lru list with empty items
struct pending_tcp * | pending
| the connection to reuse, the fd is non-1 and is open.
int | cp_more_read_again
| The more read again value pointed to by the commpoint tcp_more_read_again pointer, so that it exists after commpoint delete.
int | cp_more_write_again
| The more write again value pointed to by the commpoint tcp_more_write_again pointer, so that it exists after commpoint delete.
rbtree_type | tree_by_id
| rbtree with other queries waiting on the connection, by ID number, of type struct waiting_tcp.
struct waiting_tcp * | write_wait_first
| 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.
struct waiting_tcp * | write_wait_last
struct outside_network * | outnet
| the outside network it is part of

## Detailed Description

Reuse TCP connection, still open can be used again.

## Field Documentation

## ◆ node

rbnode_type reuse_tcp::node

rbtree node with links in tcp_reuse tree.

key is NULL when not in tree. Both active and empty connections are in the tree. key is a pointer to this structure, the members used to compare are the sockaddr and and then is-ssl bool, and then ptr value is used in case the same address exists several times in the tree when there are multiple connections to the same destination to make the rbtree items unique.

Referenced by decommission_pending_tcp(), outnet_tcp_cb(), outnet_tcp_take_into_use(), reuse_tcp_find(), reuse_tcp_insert(), reuse_tcp_remove_serviced_keep(), reuse_tcp_remove_tree_list(), and reuse_tcp_select_id().

## ◆ addr

struct sockaddr_storage reuse_tcp::addr

the key for the tcp_reuse tree.

address of peer, ip4 or ip6, and port number of peer

Referenced by log_reuse_tcp(), outnet_tcp_cb(), pending_tcp_query(), reuse_cmp_addrportssl(), reuse_tcp_find(), reuse_tcp_remove_tree_list(), and use_free_buffer().

## ◆ tls_auth_name

char* reuse_tcp::tls_auth_name

If is_ssl is enabled, tls_auth_name is part of the key for tcp_reuse tree.

If the string is NULL, it without a tls_auth_name

Referenced by decommission_pending_tcp(), outnet_tcp_take_into_use(), outside_network_delete(), reuse_cmp_addrportssl(), and reuse_tcp_find().

## ◆ lru_next

struct reuse_tcp* reuse_tcp::lru_next

lru chain, so that the oldest can be removed to get a new connection when all are in (re)use.

oldest is last in list. The lru only contains empty connections waiting for reuse, 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.

Referenced by check_removal(), check_tree_and_list(), reuse_tcp_insert(), reuse_tcp_lru_snip(), reuse_tcp_lru_touch(), reuse_tcp_remove_tree_list(), and tcp_reuse_tree_list_test().

## ◆ pending

struct pending_tcp* reuse_tcp::pending

the connection to reuse, the fd is non-1 and is open.

the addr and port determine where the connection is going, 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.

Referenced by log_reuse_tcp(), outnet_tcp_take_into_use(), pending_tcp_query(), reuse_tcp_close_oldest(), reuse_tcp_find(), reuse_tcp_insert(), reuse_tcp_remove_tree_list(), tcpid_addmore(), tcpid_test(), and use_free_buffer().

## ◆ tree_by_id

rbtree_type reuse_tcp::tree_by_id

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. The write_wait elements are also in the tree, so that ID numbers can be looked up also for them. They are bool write_wait_queued.

Referenced by decommission_pending_tcp(), outnet_tcp_cb(), pending_tcp_query(), reuse_cb_and_decommission(), reuse_tcp_by_id_find(), reuse_tcp_select_id(), reuse_tree_by_id_delete(), reuse_tree_by_id_insert(), tcpid_fillup(), tcpid_test(), and use_free_buffer().

## ◆ write_wait_first

struct waiting_tcp* reuse_tcp::write_wait_first

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. They are also in the tree_by_id. Once written, the are removed from this list, but stay in the tree.

Referenced by check_reuse_write_wait_removal(), decommission_pending_tcp(), outnet_tcp_cb(), reuse_cb_and_decommission(), reuse_write_wait_clear(), reuse_write_wait_pop(), reuse_write_wait_push_back(), and reuse_write_wait_remove().

The documentation for this struct was generated from the following file:

- services/outside_network.h