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

sul: improve debugging

This commit is contained in:
Andy Green 2021-06-26 08:28:04 +01:00
parent c0680fa2b6
commit 9e8eb28c72
3 changed files with 20 additions and 2 deletions

View file

@ -248,7 +248,7 @@ __lws_free_wsi(struct lws *wsi)
wsi->a.context->pt[(int)wsi->tsi].fds_count);
/* confirm no sul left scheduled in wsi itself */
lws_sul_debug_zombies(wsi->a.context, wsi, sizeof(wsi), __func__);
lws_sul_debug_zombies(wsi->a.context, wsi, sizeof(*wsi), __func__);
__lws_lc_untag(&wsi->lc);
lws_free(wsi);

View file

@ -81,6 +81,8 @@ lws_sul2_schedule(struct lws_context *context, int tsi, int flags,
lws_pt_assert_lock_held(pt);
assert(sul->cb);
__lws_sul_insert(
&pt->pt_sul_owner[!!(flags & LWSSULLI_WAKE_IF_SUSPENDED)], sul);
}
@ -272,6 +274,8 @@ lws_sul_schedule(struct lws_context *ctx, int tsi, lws_sorted_usec_list_t *sul,
{
struct lws_context_per_thread *_pt = &ctx->pt[tsi];
assert(_cb);
lws_pt_lock(_pt, __func__);
if (_us == (lws_usec_t)LWS_SET_TIMER_USEC_CANCEL)
@ -292,6 +296,8 @@ lws_sul_schedule_wakesuspend(struct lws_context *ctx, int tsi,
{
struct lws_context_per_thread *_pt = &ctx->pt[tsi];
assert(_cb);
lws_pt_lock(_pt, __func__);
if (_us == (lws_usec_t)LWS_SET_TIMER_USEC_CANCEL)
@ -334,12 +340,19 @@ lws_sul_debug_zombies(struct lws_context *ctx, void *po, size_t len,
lws_container_of(p,
lws_sorted_usec_list_t, list);
if (!po) {
lwsl_err("%s: %s\n", __func__, destroy_description);
/* just sanity check the list */
assert(sul->cb);
}
/*
* Is the sul resident inside the object that is
* indicated as being deleted?
*/
if ((void *)sul >= po &&
if (po &&
(void *)sul >= po &&
(size_t)lws_ptr_diff(sul, po) < len) {
lwsl_err("%s: ERROR: Zombie Sul "
"(on list %d) %s, cb %p\n",

View file

@ -717,6 +717,11 @@ lws_sspc_destroy(lws_sspc_handle_t **ph)
lws_sul_cancel(&h->sul_retry);
__lws_lc_untag(&h->lc);
/* confirm no sul left scheduled in handle or user allocation object */
lws_sul_debug_zombies(h->context, h, sizeof(*h) + h->ssi.user_alloc,
__func__);
free(h);
}