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

libuv: fix pt derivation from ptpr in callbacks

The per-pt priv for event libs ended up overallocated at the context,
and pointed-to by a single pointer composed into each pt.  That means
we can't do pointer arithmetic on it any more.

Update a couple of stragglers in libuv event lib to use a pointer in
the pt-priv for the event lib back to the pt instead.

Also in foreign case if we start idle, there may not be anything
happening to trigger the initial idle.  So let each pt start with
its idle active.
This commit is contained in:
Andy Green 2020-09-10 08:06:56 +01:00
parent 5c7b5af92a
commit 6a32db56bc
2 changed files with 6 additions and 5 deletions

View file

@ -37,8 +37,7 @@ lws_uv_sultimer_cb(uv_timer_t *timer
{
struct lws_pt_eventlibs_libuv *ptpr = lws_container_of(timer,
struct lws_pt_eventlibs_libuv, sultimer);
struct lws_context_per_thread *pt = lws_container_of(ptpr,
struct lws_context_per_thread, evlib_pt);
struct lws_context_per_thread *pt = ptpr->pt;
lws_usec_t us;
lws_pt_lock(pt, __func__);
@ -58,8 +57,7 @@ lws_uv_idle(uv_idle_t *handle
)
{ struct lws_pt_eventlibs_libuv *ptpr = lws_container_of(handle,
struct lws_pt_eventlibs_libuv, idle);
struct lws_context_per_thread *pt = lws_container_of(ptpr,
struct lws_context_per_thread, evlib_pt);
struct lws_context_per_thread *pt = ptpr->pt;
lws_usec_t us;
lws_service_do_ripe_rxflow(pt);
@ -637,6 +635,8 @@ elops_init_pt_uv(struct lws_context *context, void *_loop, int tsi)
int status = 0, n, ns, first = 1;
uv_loop_t *loop = (uv_loop_t *)_loop;
ptpriv->pt = pt;
if (!ptpriv->io_loop) {
if (!loop) {
loop = lws_malloc(sizeof(*loop), "libuv loop");
@ -659,7 +659,7 @@ elops_init_pt_uv(struct lws_context *context, void *_loop, int tsi)
ptpriv->io_loop = loop;
uv_idle_init(loop, &ptpriv->idle);
LWS_UV_REFCOUNT_STATIC_HANDLE_NEW(&ptpriv->idle, context);
uv_idle_start(&ptpriv->idle, lws_uv_idle);
ns = LWS_ARRAY_SIZE(sigs);
if (lws_check_opt(context->options,

View file

@ -53,6 +53,7 @@ struct lws_signal_watcher_libuv {
struct lws_pt_eventlibs_libuv {
uv_loop_t *io_loop;
struct lws_context_per_thread *pt;
uv_signal_t signals[8];
uv_timer_t sultimer;
uv_idle_t idle;