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