uasync: добавить отладку poll→fd/rev, timer→имя при разрешении событий
This commit is contained in:
1 parent
758ab88f7d
commit
12855de31d
1 file changed
+11
-4
+11
-4
@@ -450,6 +450,7 @@ static void process_timeouts(struct UASYNC* ua) {
|
||||
}
|
||||
|
||||
if (node && node->callback) {
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_UASYNC, "timer→immediate %s", node->name[0] ? node->name : "");
|
||||
node->callback(node->arg);
|
||||
}
|
||||
|
||||
@@ -475,7 +476,7 @@ static void process_timeouts(struct UASYNC* ua) {
|
||||
struct timeout_node* node = (struct timeout_node*)entry.data;
|
||||
|
||||
if (node && node->callback) {
|
||||
// Execute callback only if not cancelled
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_UASYNC, "timer→%s expired", node->name[0] ? node->name : "");
|
||||
node->callback(node->arg);
|
||||
}
|
||||
|
||||
@@ -920,6 +921,8 @@ static void process_epoll_events(struct UASYNC* ua, struct epoll_event* events,
|
||||
// Socket event — save node fields locally: callbacks may realloc
|
||||
// the socket array, invalidating `node`.
|
||||
struct socket_node* node = socket_array_get(ua->sockets, events[i].data.fd);
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_UASYNC, "poll→fd=%d ev=0x%x%s", events[i].data.fd, events[i].events,
|
||||
!node || !node->active ? " (inactive)" : "");
|
||||
if (!node || !node->active) continue;
|
||||
int local_fd = node->fd;
|
||||
socket_t local_sock = node->sock;
|
||||
@@ -972,7 +975,9 @@ void uasync_poll(struct UASYNC* ua, int timeout_tb) {
|
||||
if (!ua) return;
|
||||
if (!ua->sockets || !ua->timeout_heap) return;
|
||||
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_TIMERS, "poll");
|
||||
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);
|
||||
|
||||
// Handle negative or zero timeout
|
||||
if (timeout_tb < 0) timeout_tb = -1; // Infinite wait
|
||||
@@ -1135,7 +1140,8 @@ void uasync_poll(struct UASYNC* ua, int timeout_tb) {
|
||||
int has_write = FD_ISSET(s, &write_fds);
|
||||
int has_except = FD_ISSET(s, &except_fds);
|
||||
|
||||
if (!has_read && !has_write && !has_except) continue;
|
||||
if (!has_read && !has_write && !has_except) continue;
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_UASYNC, "select→fd=%d r=%d w=%d e=%d", (int)s, has_read, has_write, has_except);
|
||||
|
||||
if (has_except) {
|
||||
if (node->except_cbk) {
|
||||
@@ -1193,7 +1199,8 @@ void uasync_poll(struct UASYNC* ua, int timeout_tb) {
|
||||
/* Process socket events first to give sockets higher priority */
|
||||
if (ret > 0) {
|
||||
for (int i = 0; i < ua->poll_fds_count; i++) {
|
||||
if (ua->poll_fds[i].revents == 0) continue;
|
||||
if (ua->poll_fds[i].revents == 0) continue;
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_UASYNC, "poll→fd=%d rev=0x%x", ua->poll_fds[i].fd, ua->poll_fds[i].revents);
|
||||
|
||||
/* Handle wakeup fd separately */
|
||||
if (wakeup_fd_present && i == 0) {
|
||||
|
||||
Reference in new issue
Block a user