1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

lws_dll: upgrade all instances to lws_dll2

lws_dll2 removes the downsides of lws_dll and adds new features like a
running member count and explicit owner type... it's cleaner and more
robust (eg, nodes know their owner, so they can casually switch between
list owners and remove themselves without the code knowing the owner).

This deprecates lws_dll, but since it's public it allows it to continue
to be built for 4.0 release if you give cmake LWS_WITH_DEPRECATED_LWS_DLL.

All remaining internal users of lws_dll are migrated to lws_dll2.
This commit is contained in:
Andy Green 2019-08-08 16:58:55 +01:00
parent fed78bef42
commit 45ec3ce369
23 changed files with 130 additions and 134 deletions

View file

@ -129,6 +129,7 @@ option(LWS_WITH_LEJP_CONF "With LEJP configuration parser as used by lwsws" OFF)
option(LWS_WITH_ZLIB "Include zlib support (required for extensions)" OFF)
option(LWS_WITH_BUNDLED_ZLIB "Use bundled zlib version (Windows only)" ${LWS_WITH_BUNDLED_ZLIB_DEFAULT})
option(LWS_WITH_MINIZ "Use miniz instead of zlib" OFF)
option(LWS_WITH_DEPRECATED_LWS_DLL "Migrate to lws_dll2 instead ASAP" OFF)
#
# to use miniz, enable both LWS_WITH_ZLIB and LWS_WITH_MINIZ
#
@ -934,7 +935,6 @@ set(SOURCES
lib/core/alloc.c
lib/core/buflist.c
lib/core/context.c
lib/core/lws_dll.c
lib/core/lws_dll2.c
lib/core/libwebsockets.c
lib/core/logs.c
@ -942,6 +942,11 @@ set(SOURCES
lib/core/vfs.c
lib/misc/lws-ring.c
)
if (LWS_WITH_DEPRECATED_LWS_DLL)
list(APPEND SOURCES
lib/core/lws_dll.c)
endif()
if (LWS_WITH_NETWORK)
list(APPEND SOURCES

View file

@ -95,6 +95,7 @@
#cmakedefine LWS_WITH_BORINGSSL
#cmakedefine LWS_WITH_CGI
#cmakedefine LWS_WITH_CUSTOM_HEADERS
#cmakedefine LWS_WITH_DEPRECATED_LWS_DLL
#cmakedefine LWS_WITH_DIR
#cmakedefine LWS_WITH_ESP32
#cmakedefine LWS_WITH_FTS

View file

@ -171,6 +171,14 @@
* doubly linked-list
*/
#if defined (LWS_WITH_DEPRECATED_LWS_DLL)
/*
* This is going away in v4.1. You can set the cmake option above to keep it
* around temporarily. Migrate your stuff to the more capable and robust
* lws_dll2 below
*/
struct lws_dll {
struct lws_dll *prev;
struct lws_dll *next;
@ -219,6 +227,7 @@ lws_dll_foreach_safe(struct lws_dll *phead, void *user,
#define lws_dll_is_detached(___dll, __head) \
(!(___dll)->prev && !(___dll)->next && (__head)->prev != (___dll))
#endif
/*
* lws_dll2_owner / lws_dll2 : more capable version of lws_dll. Differences:

View file

@ -44,8 +44,7 @@ __lws_free_wsi(struct lws *wsi)
wsi->vhost->lserv_wsi = NULL;
#if !defined(LWS_NO_CLIENT)
if (wsi->vhost)
lws_dll_remove_track_tail(&wsi->dll_cli_active_conns,
&wsi->vhost->dll_cli_active_conns_head);
lws_dll2_remove(&wsi->dll_cli_active_conns);
#endif
wsi->context->count_wsi_allocated--;
@ -164,8 +163,7 @@ __lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason,
if (wsi->vhost) {
/* we are no longer an active client connection that can piggyback */
lws_dll_remove_track_tail(&wsi->dll_cli_active_conns,
&wsi->vhost->dll_cli_active_conns_head);
lws_dll2_remove(&wsi->dll_cli_active_conns);
if (rl != -1l)
lws_vhost_lock(wsi->vhost);
@ -438,7 +436,7 @@ just_kill_connection:
*/
__lws_ssl_remove_wsi_from_buffered_list(wsi);
__lws_remove_from_timeout_list(wsi);
lws_dll_remove_track_tail(&wsi->dll_hrtimer, &pt->dll_hrtimer_head);
lws_dll2_remove(&wsi->dll_hrtimer);
//if (wsi->told_event_loop_closed) // cgi std close case (dummy-callback)
// return;

View file

@ -84,7 +84,7 @@ stream_close(struct lws *wsi)
#endif
struct lws_proxy_pkt {
struct lws_dll pkt_list;
struct lws_dll2 pkt_list;
size_t len;
char binary;
char first;
@ -99,7 +99,7 @@ lws_callback_ws_proxy(struct lws *wsi, enum lws_callback_reasons reason,
void *user, void *in, size_t len)
{
struct lws_proxy_pkt *pkt;
struct lws_dll *dll;
struct lws_dll2 *dll;
switch (reason) {
@ -162,12 +162,12 @@ lws_callback_ws_proxy(struct lws *wsi, enum lws_callback_reasons reason,
memcpy(((uint8_t *)&pkt[1]) + LWS_PRE, in, len);
lws_dll_add_tail(&pkt->pkt_list, &wsi->parent->ws->proxy_head);
lws_dll2_add_tail(&pkt->pkt_list, &wsi->parent->ws->proxy_owner);
lws_callback_on_writable(wsi->parent);
break;
case LWS_CALLBACK_CLIENT_WRITEABLE:
dll = lws_dll_get_tail(&wsi->ws->proxy_head);
dll = lws_dll2_get_tail(&wsi->ws->proxy_owner);
if (!dll)
break;
@ -180,10 +180,10 @@ lws_callback_ws_proxy(struct lws *wsi, enum lws_callback_reasons reason,
wsi->parent->ws->proxy_buffered -= pkt->len;
lws_dll_remove_track_tail(dll, &wsi->ws->proxy_head);
lws_dll2_remove(dll);
lws_free(pkt);
if (lws_dll_get_tail(&wsi->ws->proxy_head))
if (lws_dll2_get_tail(&wsi->ws->proxy_owner))
lws_callback_on_writable(wsi);
break;
@ -209,12 +209,12 @@ lws_callback_ws_proxy(struct lws *wsi, enum lws_callback_reasons reason,
memcpy(((uint8_t *)&pkt[1]) + LWS_PRE, in, len);
lws_dll_add_tail(&pkt->pkt_list, &wsi->child_list->ws->proxy_head);
lws_dll2_add_tail(&pkt->pkt_list, &wsi->child_list->ws->proxy_owner);
lws_callback_on_writable(wsi->child_list);
break;
case LWS_CALLBACK_SERVER_WRITEABLE:
dll = lws_dll_get_tail(&wsi->ws->proxy_head);
dll = lws_dll2_get_tail(&wsi->ws->proxy_owner);
if (!dll)
break;
@ -225,10 +225,10 @@ lws_callback_ws_proxy(struct lws *wsi, enum lws_callback_reasons reason,
pkt->first, pkt->final)) < 0)
return -1;
lws_dll_remove_track_tail(dll, &wsi->ws->proxy_head);
lws_dll2_remove(dll);
lws_free(pkt);
if (lws_dll_get_tail(&wsi->ws->proxy_head))
if (lws_dll2_get_tail(&wsi->ws->proxy_owner))
lws_callback_on_writable(wsi);
break;

View file

@ -498,13 +498,9 @@ lws_same_vh_protocol_insert(struct lws *wsi, int n)
{
lws_vhost_lock(wsi->vhost);
if (!lws_dll_is_detached(&wsi->same_vh_protocol,
&wsi->vhost->same_vh_protocol_heads[n]))
lws_dll_remove_track_tail(&wsi->same_vh_protocol,
&wsi->vhost->same_vh_protocol_heads[n]);
lws_dll_add_head(&wsi->same_vh_protocol,
&wsi->vhost->same_vh_protocol_heads[n]);
lws_dll2_remove(&wsi->same_vh_protocol);
lws_dll2_add_head(&wsi->same_vh_protocol,
&wsi->vhost->same_vh_protocol_owner[n]);
wsi->bound_vhost_index = n;
@ -514,15 +510,8 @@ lws_same_vh_protocol_insert(struct lws *wsi, int n)
void
__lws_same_vh_protocol_remove(struct lws *wsi)
{
struct lws_dll *head;
if (!wsi->vhost || !wsi->vhost->same_vh_protocol_heads)
return;
head = &wsi->vhost->same_vh_protocol_heads[(int)wsi->bound_vhost_index];
if (!lws_dll_is_detached(&wsi->same_vh_protocol, head))
lws_dll_remove_track_tail(&wsi->same_vh_protocol, head);
if (wsi->vhost && wsi->vhost->same_vh_protocol_owner)
lws_dll2_remove(&wsi->same_vh_protocol);
}
void
@ -557,8 +546,8 @@ lws_callback_on_writable_all_protocol_vhost(const struct lws_vhost *vhost,
n = (int)(protocol - vhost->protocols);
lws_start_foreach_dll_safe(struct lws_dll *, d, d1,
vhost->same_vh_protocol_heads[n].next) {
lws_start_foreach_dll_safe(struct lws_dll2 *, d, d1,
lws_dll2_get_head(&vhost->same_vh_protocol_owner[n])) {
wsi = lws_container_of(d, struct lws, same_vh_protocol);
assert(wsi->protocol == protocol);

View file

@ -277,8 +277,8 @@ struct lws_context_per_thread {
*/
unsigned char *serv_buf;
struct lws_dll dll_timeout_head;
struct lws_dll dll_hrtimer_head;
struct lws_dll2_owner dll_timeout_owner;
struct lws_dll2_owner dll_hrtimer_head;
struct lws_dll2_owner dll_buflist_owner; /* guys with pending rxflow */
struct lws_dll2_owner seq_owner; /* list of lws_sequencer-s */
struct lws_dll2_owner seq_pend_owner; /* lws_seq-s with pending evts */
@ -428,12 +428,12 @@ struct lws_vhost {
void **protocol_vh_privs;
const struct lws_protocol_vhost_options *pvo;
const struct lws_protocol_vhost_options *headers;
struct lws_dll *same_vh_protocol_heads;
struct lws_dll2_owner *same_vh_protocol_owner;
struct lws_vhost *no_listener_vhost_list;
struct lws_dll2_owner abstract_instances_owner;
#if !defined(LWS_NO_CLIENT)
struct lws_dll dll_cli_active_conns_head;
struct lws_dll2_owner dll_cli_active_conns_owner;
#endif
#if defined(LWS_WITH_TLS)
@ -512,12 +512,12 @@ struct lws {
struct lws *sibling_list; /* subsequent children at same level */
const struct lws_protocols *protocol;
struct lws_dll same_vh_protocol;
struct lws_dll2 same_vh_protocol;
lws_seq_t *seq; /* associated sequencer if any */
struct lws_dll dll_timeout;
struct lws_dll dll_hrtimer;
struct lws_dll2 dll_timeout;
struct lws_dll2 dll_hrtimer;
struct lws_dll2 dll_buflist; /* guys with pending rxflow */
#if defined(LWS_WITH_THREADPOOL)
@ -532,7 +532,7 @@ struct lws {
#ifndef LWS_NO_CLIENT
struct client_info_stash *stash;
char *cli_hostname_copy;
struct lws_dll dll_cli_active_conns;
struct lws_dll2 dll_cli_active_conns;
struct lws_dll2_owner dll2_cli_txn_queue_owner;
struct lws_dll2 dll2_cli_txn_queue;
#endif

View file

@ -568,8 +568,8 @@ lws_service_flag_pending(struct lws_context *context, int tsi)
* service to use up the buffered incoming data, even though their
* network socket may have nothing
*/
lws_start_foreach_dll_safe(struct lws_dll *, p, p1,
pt->tls.dll_pending_tls_head.next) {
lws_start_foreach_dll_safe(struct lws_dll2 *, p, p1,
lws_dll2_get_head(&pt->tls.dll_pending_tls_owner)) {
struct lws *wsi = lws_container_of(p, struct lws,
tls.dll_pending_tls);
@ -693,8 +693,8 @@ lws_service_periodic_checks(struct lws_context *context,
lws_pt_lock(pt, __func__);
lws_start_foreach_dll_safe(struct lws_dll *, d, d1,
context->pt[tsi].dll_timeout_head.next) {
lws_start_foreach_dll_safe(struct lws_dll2 *, d, d1,
lws_dll2_get_head(&context->pt[tsi].dll_timeout_owner)) {
wsi = lws_container_of(d, struct lws, dll_timeout);
tmp_fd = wsi->desc.sockfd;

View file

@ -631,8 +631,8 @@ lws_create_vhost(struct lws_context *context,
vh->protocols = lwsp;
vh->allocated_vhost_protocols = 1;
vh->same_vh_protocol_heads = (struct lws_dll *)
lws_zalloc(sizeof(struct lws_dll) *
vh->same_vh_protocol_owner = (struct lws_dll2_owner *)
lws_zalloc(sizeof(struct lws_dll2_owner) *
vh->count_protocols, "same vh list");
#if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2)
vh->http.mount_list = info->mounts;
@ -1088,7 +1088,7 @@ __lws_vhost_destroy2(struct lws_vhost *vh)
if (vh->protocol_vh_privs)
lws_free(vh->protocol_vh_privs);
lws_ssl_SSL_CTX_destroy(vh);
lws_free(vh->same_vh_protocol_heads);
lws_free(vh->same_vh_protocol_owner);
if (context->plugin_list ||
(context->options & LWS_SERVER_OPTION_EXPLICIT_VHOSTS) ||

View file

@ -24,9 +24,7 @@
void
__lws_remove_from_timeout_list(struct lws *wsi)
{
struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
lws_dll_remove_track_tail(&wsi->dll_timeout, &pt->dll_timeout_head);
lws_dll2_remove(&wsi->dll_timeout);
}
void
@ -41,39 +39,40 @@ lws_remove_from_timeout_list(struct lws *wsi)
void
__lws_set_timer_usecs(struct lws *wsi, lws_usec_t usecs)
__lws_set_timer_usecs(struct lws *wsi, lws_usec_t us)
{
struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
struct lws_dll *target = NULL;
struct timeval now;
struct lws *wsi1;
int bef = 0;
lws_dll_remove_track_tail(&wsi->dll_hrtimer, &pt->dll_hrtimer_head);
lws_dll2_remove(&wsi->dll_hrtimer);
if (usecs == LWS_SET_TIMER_USEC_CANCEL)
if (us == LWS_SET_TIMER_USEC_CANCEL)
return;
gettimeofday(&now, NULL);
wsi->pending_timer = ((now.tv_sec * 1000000ll) + now.tv_usec) + usecs;
wsi->pending_timer = lws_now_usecs() + us;
/*
* we sort the hrtimer list with the earliest timeout first
*/
lws_start_foreach_dll_safe(struct lws_dll *, d, d1,
pt->dll_hrtimer_head.next) {
target = d;
wsi1 = lws_container_of(d, struct lws, dll_hrtimer);
lws_start_foreach_dll_safe(struct lws_dll2 *, p, tp,
pt->dll_hrtimer_head.head) {
struct lws *w = lws_container_of(p, struct lws, dll_hrtimer);
if (wsi1->pending_timer >= wsi->pending_timer) {
/* d, dprev's next, is >= our time */
bef = 1;
break;
assert(w->pending_timer); /* shouldn't be on the list otherwise */
if (w->pending_timer >= wsi->pending_timer) {
/* drop us in before this guy */
lws_dll2_add_before(&wsi->dll_hrtimer, &w->dll_hrtimer);
return;
}
} lws_end_foreach_dll_safe(d, d1);
} lws_end_foreach_dll_safe(p, tp);
lws_dll_insert(&wsi->dll_hrtimer, target, &pt->dll_hrtimer_head, bef);
/*
* Either nobody on the list yet to compare him to, or he's the
* longest timeout... stick him at the tail end
*/
lws_dll2_add_tail(&wsi->dll_hrtimer, &pt->dll_hrtimer_head);
}
LWS_VISIBLE void
@ -89,8 +88,8 @@ __lws_hrtimer_service(struct lws_context_per_thread *pt, lws_usec_t t)
{
struct lws *wsi;
lws_start_foreach_dll_safe(struct lws_dll *, d, d1,
pt->dll_hrtimer_head.next) {
lws_start_foreach_dll_safe(struct lws_dll2 *, d, d1,
lws_dll2_get_head(&pt->dll_hrtimer_head)) {
wsi = lws_container_of(d, struct lws, dll_hrtimer);
/*
@ -113,11 +112,11 @@ __lws_hrtimer_service(struct lws_context_per_thread *pt, lws_usec_t t)
/* return an estimate how many us until next timer hit */
if (!pt->dll_hrtimer_head.next)
if (!lws_dll2_get_head(&pt->dll_hrtimer_head))
return 0; /* there is nothing pending */
wsi = lws_container_of(pt->dll_hrtimer_head.next, struct lws,
dll_hrtimer);
wsi = lws_container_of(lws_dll2_get_head(&pt->dll_hrtimer_head),
struct lws, dll_hrtimer);
t = lws_now_usecs();
if (wsi->pending_timer <= t) /* in the past */
@ -134,14 +133,17 @@ __lws_set_timeout(struct lws *wsi, enum pending_timeout reason, int secs)
time(&now);
lwsl_debug("%s: %p: %d secs (reason %d)\n", __func__, wsi, secs, reason);
lwsl_debug("%s: %p: %d secs, reason %d\n", __func__, wsi, secs, reason);
wsi->pending_timeout_limit = secs;
wsi->pending_timeout_set = now;
wsi->pending_timeout = reason;
lws_dll_remove_track_tail(&wsi->dll_timeout, &pt->dll_timeout_head);
if (reason)
lws_dll_add_head(&wsi->dll_timeout, &pt->dll_timeout_head);
lws_dll2_remove(&wsi->dll_timeout);
if (!reason)
return;
lws_dll2_add_head(&wsi->dll_timeout, &pt->dll_timeout_owner);
}
LWS_VISIBLE void

View file

@ -288,7 +288,7 @@ lws_dbus_add_timeout(DBusTimeout *t, void *data)
dbt->fire = ti + (ms < 1000);
dbt->timer_list.prev = NULL;
dbt->timer_list.next = NULL;
lws_dll_add_front(&dbt->timer_list, &pt->dbus.timer_list_head);
lws_dll2_add_head(&dbt->timer_list, &pt->dbus.timer_list_owner);
ctx->timeouts++;
@ -303,12 +303,12 @@ lws_dbus_remove_timeout(DBusTimeout *t, void *data)
lwsl_info("%s: t %p, data %p\n", __func__, t, data);
lws_start_foreach_dll_safe(struct lws_dll *, rdt, nx,
pt->dbus.timer_list_head.next) {
lws_start_foreach_dll_safe(struct lws_dll2 *, rdt, nx,
lws_dll2_get_head(&pt->dbus.timer_list_owner)) {
struct lws_role_dbus_timer *r = lws_container_of(rdt,
struct lws_role_dbus_timer, timer_list);
if (t == r->data) {
lws_dll_remove_track_tail(rdt, &pt->dbus.timer_list_head);
lws_dll2_remove(rdt);
lws_free(rdt);
ctx->timeouts--;
break;
@ -480,15 +480,15 @@ rops_periodic_checks_dbus(struct lws_context *context, int tsi, time_t now)
* service thread can modify stuff on the same pt.
*/
lws_start_foreach_dll_safe(struct lws_dll *, rdt, nx,
pt->dbus.timer_list_head.next) {
lws_start_foreach_dll_safe(struct lws_dll2 *, rdt, nx,
lws_dll2_get_head(&pt->dbus.timer_list_owner)) {
struct lws_role_dbus_timer *r = lws_container_of(rdt,
struct lws_role_dbus_timer, timer_list);
if (now > r->fire) {
lwsl_notice("%s: firing timer\n", __func__);
dbus_timeout_handle(r->data);
lws_dll_remove_track_tail(rdt, &pt->dbus.timer_list_head);
lws_dll2_remove(rdt);
lws_free(rdt);
}
} lws_end_foreach_dll_safe(rdt, nx);

View file

@ -28,13 +28,13 @@ extern struct lws_role_ops role_ops_dbus;
#define lwsi_role_dbus(wsi) (wsi->role_ops == &role_ops_dbus)
struct lws_role_dbus_timer {
struct lws_dll timer_list;
struct lws_dll2 timer_list;
void *data;
time_t fire;
};
struct lws_pt_role_dbus {
struct lws_dll timer_list_head;
struct lws_dll2_owner timer_list_owner;
};
struct _lws_dbus_mode_related {

View file

@ -270,8 +270,8 @@ lws_client_connect_2(struct lws *wsi)
lws_vhost_lock(wsi->vhost); /* ----------------------------------- { */
lws_start_foreach_dll_safe(struct lws_dll *, d, d1,
wsi->vhost->dll_cli_active_conns_head.next) {
lws_start_foreach_dll_safe(struct lws_dll2 *, d, d1,
lws_dll2_get_head(&wsi->vhost->dll_cli_active_conns_owner)) {
struct lws *w = lws_container_of(d, struct lws,
dll_cli_active_conns);
@ -367,12 +367,11 @@ create_new_conn:
if (meth && (!strcmp(meth, "GET") || !strcmp(meth, "POST")) &&
lws_dll2_is_detached(&wsi->dll2_cli_txn_queue) &&
lws_dll_is_detached(&wsi->dll_cli_active_conns,
&wsi->vhost->dll_cli_active_conns_head)) {
lws_dll2_is_detached(&wsi->dll_cli_active_conns)) {
lws_vhost_lock(wsi->vhost);
/* caution... we will have to unpick this on oom4 path */
lws_dll_add_head(&wsi->dll_cli_active_conns,
&wsi->vhost->dll_cli_active_conns_head);
lws_dll2_add_head(&wsi->dll_cli_active_conns,
&wsi->vhost->dll_cli_active_conns_owner);
lws_vhost_unlock(wsi->vhost);
}

View file

@ -604,8 +604,7 @@ lws_http_transaction_completed_client(struct lws *wsi)
* If not, that's it for us.
*/
if (lws_dll_is_detached(&wsi->dll_cli_active_conns,
&wsi->vhost->dll_cli_active_conns_head))
if (lws_dll2_is_detached(&wsi->dll_cli_active_conns))
return -1;
/* if this was a queued guy, close him and remove from queue */

View file

@ -1497,12 +1497,13 @@ rops_periodic_checks_ws(struct lws_context *context, int tsi, time_t now)
for (n = 0; n < vh->count_protocols; n++) {
lws_start_foreach_dll_safe(struct lws_dll *, d, d1,
vh->same_vh_protocol_heads[n].next) {
lws_start_foreach_dll_safe(struct lws_dll2 *, d, d1,
lws_dll2_get_head(&vh->same_vh_protocol_owner[n])) {
struct lws *wsi = lws_container_of(d,
struct lws, same_vh_protocol);
if (lwsi_role_ws(wsi) && !wsi->http2_substream &&
if (lwsi_role_ws(wsi) &&
!wsi->http2_substream &&
!wsi->socket_is_permanently_unusable &&
!wsi->ws->send_check_ping &&
wsi->ws->time_next_ping_check &&
@ -1510,7 +1511,8 @@ rops_periodic_checks_ws(struct lws_context *context, int tsi, time_t now)
wsi->ws->time_next_ping_check) >
context->ws_ping_pong_interval) {
lwsl_info("%s: req pp on wsi %p\n", __func__, wsi);
lwsl_info("%s: req pp on wsi %p\n",
__func__, wsi);
wsi->ws->send_check_ping = 1;
lws_set_timeout(wsi,
PENDING_TIMEOUT_WS_PONG_CHECK_SEND_PING,
@ -1523,6 +1525,7 @@ rops_periodic_checks_ws(struct lws_context *context, int tsi, time_t now)
}
lws_vhost_unlock(vh);
vh = vh->vhost_next;
}
@ -2072,7 +2075,7 @@ rops_destroy_vhost_ws(struct lws_vhost *vh)
#if defined(LWS_WITH_HTTP_PROXY)
static int
ws_destroy_proxy_buf(struct lws_dll *d, void *user)
ws_destroy_proxy_buf(struct lws_dll2 *d, void *user)
{
lws_free(d);
@ -2084,7 +2087,7 @@ static int
rops_destroy_role_ws(struct lws *wsi)
{
#if defined(LWS_WITH_HTTP_PROXY)
lws_dll_foreach_safe(&wsi->ws->proxy_head, NULL, ws_destroy_proxy_buf);
lws_dll2_foreach_safe(&wsi->ws->proxy_owner, NULL, ws_destroy_proxy_buf);
#endif
lws_free_set_NULL(wsi->ws);

View file

@ -94,7 +94,7 @@ struct _lws_websocket_related {
#endif
#if defined(LWS_WITH_HTTP_PROXY)
struct lws_dll proxy_head;
struct lws_dll2_owner proxy_owner;
char actual_protocol[16];
size_t proxy_buffered;
#endif

View file

@ -125,10 +125,9 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
goto bail;
if (SSL_pending(wsi->tls.ssl) &&
lws_dll_is_detached(&wsi->tls.dll_pending_tls,
&pt->tls.dll_pending_tls_head))
lws_dll_add_head(&wsi->tls.dll_pending_tls,
&pt->tls.dll_pending_tls_head);
lws_dll2_is_detached(&wsi->tls.dll_pending_tls))
lws_dll2_add_head(&wsi->tls.dll_pending_tls,
&pt->tls.dll_pending_tls_owner);
return n;
bail:

View file

@ -480,8 +480,8 @@ lws_tls_client_create_vhost_context(struct lws_vhost *vh,
/* look for existing client context with same config already */
lws_start_foreach_dll_safe(struct lws_dll *, p, tp,
vh->context->tls.cc_head.next) {
lws_start_foreach_dll_safe(struct lws_dll2 *, p, tp,
lws_dll2_get_head(&vh->context->tls.cc_owner)) {
tcr = lws_container_of(p, struct lws_tls_client_reuse, cc_list);
if (!memcmp(hash, tcr->hash, len)) {
@ -522,7 +522,7 @@ lws_tls_client_create_vhost_context(struct lws_vhost *vh,
tcr->refcount = 1;
memcpy(tcr->hash, hash, len);
tcr->index = vh->context->tls.count_client_contexts++;
lws_dll_add_front(&tcr->cc_list, &vh->context->tls.cc_head);
lws_dll2_add_head(&tcr->cc_list, &vh->context->tls.cc_owner);
lwsl_info("%s: vh %s: created new client ctx %d\n", __func__,
vh->name, tcr->index);

View file

@ -632,10 +632,9 @@ lws_tls_server_accept(struct lws *wsi)
lws_openssl_describe_cipher(wsi);
if (SSL_pending(wsi->tls.ssl) &&
lws_dll_is_detached(&wsi->tls.dll_pending_tls,
&pt->tls.dll_pending_tls_head))
lws_dll_add_head(&wsi->tls.dll_pending_tls,
&pt->tls.dll_pending_tls_head);
lws_dll2_is_detached(&wsi->tls.dll_pending_tls))
lws_dll2_add_head(&wsi->tls.dll_pending_tls,
&pt->tls.dll_pending_tls_owner);
return LWS_SSL_CAPABLE_DONE;
}

View file

@ -23,13 +23,13 @@
/*
* one of these per different client context
* cc_head is in lws_context.lws_context_tls
* cc_owner is in lws_context.lws_context_tls
*/
struct lws_tls_client_reuse {
lws_tls_ctx *ssl_client_ctx;
uint8_t hash[32];
struct lws_dll cc_list;
struct lws_dll2 cc_list;
int refcount;
int index;
};

View file

@ -127,7 +127,7 @@ lws_ssl_destroy_client_ctx(struct lws_vhost *vhost)
vhost->context->tls.count_client_contexts--;
lws_dll_remove_track_tail(&tcr->cc_list, &vhost->context->tls.cc_head);
lws_dll2_remove(&tcr->cc_list);
lws_free(tcr);
}
@ -280,9 +280,9 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
goto bail;
if (SSL_pending(wsi->tls.ssl) &&
lws_dll_is_detached(&wsi->tls.dll_pending_tls, &pt->tls.dll_pending_tls_head))
lws_dll_add_head(&wsi->tls.dll_pending_tls,
&pt->tls.dll_pending_tls_head);
lws_dll2_is_detached(&wsi->tls.dll_pending_tls))
lws_dll2_add_head(&wsi->tls.dll_pending_tls,
&pt->tls.dll_pending_tls_owner);
return n;
bail:

View file

@ -31,12 +31,12 @@ struct lws_context_tls {
char alpn_discovered[32];
const char *alpn_default;
time_t last_cert_check_s;
struct lws_dll cc_head;
struct lws_dll2_owner cc_owner;
int count_client_contexts;
};
struct lws_pt_tls {
struct lws_dll dll_pending_tls_head;
struct lws_dll2_owner dll_pending_tls_owner;
};
struct lws_tls_ss_pieces;
@ -70,7 +70,7 @@ struct lws_vhost_tls {
struct lws_lws_tls {
lws_tls_conn *ssl;
lws_tls_bio *client_bio;
struct lws_dll dll_pending_tls;
struct lws_dll2 dll_pending_tls;
unsigned int use_ssl;
unsigned int redirect_to_https:1;
};

View file

@ -32,8 +32,8 @@ lws_tls_fake_POLLIN_for_buffered(struct lws_context_per_thread *pt)
{
int ret = 0;
lws_start_foreach_dll_safe(struct lws_dll *, p, p1,
pt->tls.dll_pending_tls_head.next) {
lws_start_foreach_dll_safe(struct lws_dll2 *, p, p1,
lws_dll2_get_head(&pt->tls.dll_pending_tls_owner)) {
struct lws *wsi = lws_container_of(p, struct lws,
tls.dll_pending_tls);
@ -49,14 +49,7 @@ lws_tls_fake_POLLIN_for_buffered(struct lws_context_per_thread *pt)
void
__lws_ssl_remove_wsi_from_buffered_list(struct lws *wsi)
{
struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
if (lws_dll_is_detached(&wsi->tls.dll_pending_tls,
&pt->tls.dll_pending_tls_head))
return;
lws_dll_remove_track_tail(&wsi->tls.dll_pending_tls,
&pt->tls.dll_pending_tls_head);
lws_dll2_remove(&wsi->tls.dll_pending_tls);
}
void