diff --git a/src/timer.c b/src/timer.c index 7cfca3b1fc0..9f22a64c3e7 100644 --- a/src/timer.c +++ b/src/timer.c @@ -21,6 +21,7 @@ #include "uv.h" #include "uv-common.h" #include "heap-inl.h" +#include #include @@ -162,6 +163,7 @@ int uv__next_timeout(const uv_loop_t* loop) { void uv__run_timers(uv_loop_t* loop) { + printf("Running timers\n"); struct heap_node* heap_node; uv_timer_t* handle; struct uv__queue* queue_node; @@ -191,6 +193,8 @@ void uv__run_timers(uv_loop_t* loop) { uv_timer_again(handle); handle->timer_cb(handle); } + + printf("Timers run completed\n"); } diff --git a/src/unix/core.c b/src/unix/core.c index 1dde27bd70d..8ad2a6ab740 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -423,11 +423,18 @@ int uv_loop_alive(const uv_loop_t* loop) { return uv__loop_alive(loop); } +int is_default = -1; int uv_run(uv_loop_t* loop, uv_run_mode mode) { int timeout; int r; int can_sleep; + uv_loop_t* default_loop = uv_default_loop(); + is_default = (loop == default_loop); + + if(is_default) { + printf("\nLoop started [%p]\n\n", (void*)loop); + } r = uv__loop_alive(loop); if (!r) @@ -443,6 +450,10 @@ int uv_run(uv_loop_t* loop, uv_run_mode mode) { } while (r != 0 && loop->stop_flag == 0) { + if(is_default) { + printf("\n\tStarted tick [%p]\n\n", (void*)loop); + } + can_sleep = uv__queue_empty(&loop->pending_queue) && uv__queue_empty(&loop->idle_handles); @@ -478,10 +489,17 @@ int uv_run(uv_loop_t* loop, uv_run_mode mode) { uv__run_timers(loop); r = uv__loop_alive(loop); + if (is_default) { + printf("\tFinished Tick for loop [%p]\n\n", (void*)loop); + } if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT) break; } + if (is_default) { + printf("\nLoop finished [%p]\n\n", (void*)loop); + } + /* The if statement lets gcc compile it to a conditional store. Avoids * dirtying a cache line. */ @@ -843,6 +861,11 @@ static void uv__run_pending(uv_loop_t* loop) { struct uv__queue* q; struct uv__queue pq; uv__io_t* w; + int count = 0; + + if (is_default) { + printf("\tRunning pending callbacks for loop\n"); + } uv__queue_move(&loop->pending_queue, &pq); @@ -852,6 +875,12 @@ static void uv__run_pending(uv_loop_t* loop) { uv__queue_init(q); w = uv__queue_data(q, uv__io_t, pending_queue); w->cb(loop, w, POLLOUT); + count++; + } + + if (is_default) { + printf("Ran %d pending callbacks\n", count); + printf("Finished running pending callbacks\n"); } } diff --git a/src/unix/kqueue.c b/src/unix/kqueue.c index 39b72012c26..4b15ce0271e 100644 --- a/src/unix/kqueue.c +++ b/src/unix/kqueue.c @@ -157,6 +157,7 @@ static void uv__kqueue_delete(int kqfd, const struct kevent *ev) { void uv__io_poll(uv_loop_t* loop, int timeout) { + printf("Started polling IO with timeout %d ms\n", timeout); uv__loop_internal_fields_t* lfields; struct kevent events[1024]; struct kevent* ev; @@ -243,6 +244,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { w->events = w->pevents; } + printf("Finished polling IO with timeout %d ms\n", timeout); + pset = NULL; if (loop->flags & UV_LOOP_BLOCK_SIGPROF) { pset = &set; diff --git a/src/unix/loop-watcher.c b/src/unix/loop-watcher.c index 2db8b515df7..503a228db52 100644 --- a/src/unix/loop-watcher.c +++ b/src/unix/loop-watcher.c @@ -21,6 +21,7 @@ #include "uv.h" #include "internal.h" +#include #define UV_LOOP_WATCHER_DEFINE(name, type) \ int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \ @@ -46,6 +47,7 @@ } \ \ void uv__run_##name(uv_loop_t* loop) { \ + printf("Started running %s callbacks for loop %p\n", #name, (void*)loop); \ uv_##name##_t* h; \ struct uv__queue queue; \ struct uv__queue* q; \ @@ -57,6 +59,7 @@ uv__queue_insert_tail(&loop->name##_handles, q); \ h->name##_cb(h); \ } \ + printf("Finished running %s callbacks for loop %p\n", #name, (void*)loop); \ } \ \ void uv__##name##_close(uv_##name##_t* handle) { \ diff --git a/src/unix/loop.c b/src/unix/loop.c index 5d3f0c7a348..de06abed134 100644 --- a/src/unix/loop.c +++ b/src/unix/loop.c @@ -26,12 +26,15 @@ #include #include #include +#include int uv_loop_init(uv_loop_t* loop) { uv__loop_internal_fields_t* lfields; void* saved_data; int err; + printf("Loop Initialized: %p\n", (void*)loop); + saved_data = loop->data; memset(loop, 0, sizeof(*loop)); loop->data = saved_data; diff --git a/src/uv-common.c b/src/uv-common.c index bff9d9ee1dd..c46ce86908b 100644 --- a/src/uv-common.c +++ b/src/uv-common.c @@ -901,6 +901,7 @@ int uv_loop_close(uv_loop_t* loop) { if (loop == default_loop_ptr) default_loop_ptr = NULL; + printf("Loops %p closed.\n", (void*) loop); return 0; }