- Better fix for reuse tree comparison for is-tls sockets. Where

the tree key identity is preserved after cleanup of the TLS state.
This commit is contained in:
W.C.A. Wijngaards 2020-11-25 10:22:11 +01:00
parent 15e8f5c6d4
commit 4b644b7965
3 changed files with 11 additions and 4 deletions

View file

@ -1,6 +1,8 @@
25 November 2020: Wouter 25 November 2020: Wouter
- with udp-connect ignore connection refused with UDP timeouts. - with udp-connect ignore connection refused with UDP timeouts.
- Fix udp-connect on FreeBSD, do send calls on connected UDP socket. - Fix udp-connect on FreeBSD, do send calls on connected UDP socket.
- Better fix for reuse tree comparison for is-tls sockets. Where
the tree key identity is preserved after cleanup of the TLS state.
24 November 2020: Wouter 24 November 2020: Wouter
- Merge PR #283 : Stream reuse. This implements upstream stream - Merge PR #283 : Stream reuse. This implements upstream stream

View file

@ -146,9 +146,9 @@ reuse_cmp_addrportssl(const void* key1, const void* key2)
return r; return r;
/* compare if SSL-enabled */ /* compare if SSL-enabled */
if(r1->pending->c->ssl && !r2->pending->c->ssl) if(r1->is_ssl && !r2->is_ssl)
return 1; return 1;
if(!r1->pending->c->ssl && r2->pending->c->ssl) if(!r1->is_ssl && r2->is_ssl)
return -1; return -1;
return 0; return 0;
} }
@ -465,8 +465,8 @@ reuse_tcp_find(struct outside_network* outnet, struct sockaddr_storage* addr,
key_p.c = &c; key_p.c = &c;
key_p.reuse.pending = &key_p; key_p.reuse.pending = &key_p;
key_p.reuse.node.key = &key_p.reuse; key_p.reuse.node.key = &key_p.reuse;
if(use_ssl) /* something nonNULL for comparisons in tree */ if(use_ssl)
key_p.c->ssl = (void*)1; key_p.reuse.is_ssl = 1;
if(addrlen > sizeof(key_p.reuse.addr)) if(addrlen > sizeof(key_p.reuse.addr))
return NULL; return NULL;
memmove(&key_p.reuse.addr, addr, addrlen); memmove(&key_p.reuse.addr, addr, addrlen);
@ -657,6 +657,9 @@ outnet_tcp_take_into_use(struct waiting_tcp* w)
pend->c->repinfo.addrlen = w->addrlen; pend->c->repinfo.addrlen = w->addrlen;
memcpy(&pend->c->repinfo.addr, &w->addr, w->addrlen); memcpy(&pend->c->repinfo.addr, &w->addr, w->addrlen);
pend->reuse.pending = pend; pend->reuse.pending = pend;
if(pend->c->ssl)
pend->reuse.is_ssl = 1;
else pend->reuse.is_ssl = 0;
/* insert in reuse by address tree if not already inserted there */ /* insert in reuse by address tree if not already inserted there */
(void)reuse_tcp_insert(w->outnet, pend); (void)reuse_tcp_insert(w->outnet, pend);
reuse_tree_by_id_insert(&pend->reuse, w); reuse_tree_by_id_insert(&pend->reuse, w);

View file

@ -247,6 +247,8 @@ struct reuse_tcp {
struct sockaddr_storage addr; struct sockaddr_storage addr;
/** length of addr */ /** length of addr */
socklen_t addrlen; socklen_t addrlen;
/** also key for tcp_reuse tree, if ssl is used */
int is_ssl;
/** lru chain, so that the oldest can be removed to get a new /** 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. * connection when all are in (re)use. oldest is last in list.
* The lru only contains empty connections waiting for reuse, * The lru only contains empty connections waiting for reuse,