diff --git a/lib/u_async.c b/lib/u_async.c index b6dcfbff..88661d5d 100644 --- a/lib/u_async.c +++ b/lib/u_async.c @@ -984,6 +984,13 @@ void uasync_poll(struct UASYNC* ua, int timeout_tb) { if (!ua) return; if (!ua->sockets || !ua->timeout_heap) return; + uint64_t now_us_poll_entry = get_time_us(); + if (ua->last_poll_entry_us && now_us_poll_entry - ua->last_poll_entry_us > 10000) { + DEBUG_WARN(DEBUG_CATEGORY_UASYNC, "Event loop stall: %lluus since last poll entry", + (unsigned long long)(now_us_poll_entry - ua->last_poll_entry_us)); + } + ua->last_poll_entry_us = now_us_poll_entry; + DEBUG_DEBUG(DEBUG_CATEGORY_UASYNC, "poll(%d sockets, %zu timers, timeout=%d.%dms)", ua->sockets->count, ua->timeout_heap->size, timeout_tb >= 0 ? timeout_tb / 10000 : -1, timeout_tb >= 0 ? (timeout_tb % 10000) / 10 : 0); @@ -1320,6 +1327,7 @@ struct UASYNC* uasync_create(void) { ua->posted_tasks_head = NULL; ua->immediate_queue_head = NULL; ua->immediate_queue_tail = NULL; + ua->last_poll_entry_us = 0; DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "Creating SA..."); ua->sockets = socket_array_create(16); diff --git a/lib/u_async.h b/lib/u_async.h index 6028bd59..8077bf4e 100644 --- a/lib/u_async.h +++ b/lib/u_async.h @@ -75,6 +75,7 @@ struct UASYNC { pthread_mutex_t posted_lock; #endif volatile sig_atomic_t stop; + uint64_t last_poll_entry_us; }; // Type definitions