Skip to content

With print #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: v1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "uv.h"
#include "uv-common.h"
#include "heap-inl.h"
#include <stdio.h>

#include <limits.h>

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}


Expand Down
29 changes: 29 additions & 0 deletions src/unix/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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);

Expand All @@ -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");
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/unix/kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/unix/loop-watcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "uv.h"
#include "internal.h"
#include <stdio.h>

#define UV_LOOP_WATCHER_DEFINE(name, type) \
int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \
Expand All @@ -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; \
Expand All @@ -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) { \
Expand Down
3 changes: 3 additions & 0 deletions src/unix/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>

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;
Expand Down
1 change: 1 addition & 0 deletions src/uv-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading