Add some counters for testing
This commit is contained in:
parent
6d07c0d522
commit
9400c3ffff
@ -54,15 +54,21 @@ static void do_accept(uv_handle_t* timer_handle, int status) {
|
||||
uv_tcp_t* server;
|
||||
uv_tcp_t* accepted_handle = (uv_tcp_t*)malloc(sizeof *accepted_handle);
|
||||
int r;
|
||||
int tcpcnt;
|
||||
|
||||
ASSERT(timer_handle != NULL);
|
||||
ASSERT(status == 0);
|
||||
ASSERT(accepted_handle != NULL);
|
||||
|
||||
/* Test to that uv_cnt_tcp_init increases across the uv_accept. */
|
||||
tcpcnt = uv_cnt_tcp_init;
|
||||
|
||||
server = (uv_tcp_t*)timer_handle->data;
|
||||
r = uv_accept(server, accepted_handle);
|
||||
ASSERT(r == 0);
|
||||
|
||||
ASSERT(uv_cnt_tcp_init == tcpcnt + 1);
|
||||
|
||||
do_accept_called++;
|
||||
|
||||
/* Immediately close the accepted handle. */
|
||||
@ -112,6 +118,8 @@ static void start_server() {
|
||||
|
||||
r = uv_tcp_init(server);
|
||||
ASSERT(r == 0);
|
||||
ASSERT(uv_cnt_tcp_init == 1);
|
||||
ASSERT(uv_cnt_handle_init == 1);
|
||||
|
||||
r = uv_bind(server, addr);
|
||||
ASSERT(r == 0);
|
||||
|
||||
@ -205,6 +205,8 @@ int uv_run() {
|
||||
|
||||
|
||||
static void uv__handle_init(uv_handle_t* handle, uv_handle_type type) {
|
||||
uv_cnt_handle_init++;
|
||||
|
||||
handle->type = type;
|
||||
handle->flags = 0;
|
||||
|
||||
@ -218,6 +220,7 @@ static void uv__handle_init(uv_handle_t* handle, uv_handle_type type) {
|
||||
|
||||
int uv_tcp_init(uv_tcp_t* tcp) {
|
||||
uv__handle_init((uv_handle_t*)tcp, UV_TCP);
|
||||
uv_cnt_tcp_init++;
|
||||
|
||||
tcp->alloc_cb = NULL;
|
||||
tcp->connect_req = NULL;
|
||||
@ -965,6 +968,7 @@ int uv_read_stop(uv_tcp_t* tcp) {
|
||||
|
||||
|
||||
void uv_req_init(uv_req_t* req, uv_handle_t* handle, void* cb) {
|
||||
uv_cnt_req_init++;
|
||||
req->type = UV_UNKNOWN_REQ;
|
||||
req->cb = cb;
|
||||
req->handle = handle;
|
||||
@ -983,6 +987,7 @@ static void uv__prepare(EV_P_ ev_prepare* w, int revents) {
|
||||
|
||||
int uv_prepare_init(uv_prepare_t* prepare) {
|
||||
uv__handle_init((uv_handle_t*)prepare, UV_PREPARE);
|
||||
uv_cnt_prepare_init++;
|
||||
|
||||
ev_prepare_init(&prepare->prepare_watcher, uv__prepare);
|
||||
prepare->prepare_watcher.data = prepare;
|
||||
@ -1032,6 +1037,7 @@ static void uv__check(EV_P_ ev_check* w, int revents) {
|
||||
|
||||
int uv_check_init(uv_check_t* check) {
|
||||
uv__handle_init((uv_handle_t*)check, UV_CHECK);
|
||||
uv_cnt_check_init;
|
||||
|
||||
ev_check_init(&check->check_watcher, uv__check);
|
||||
check->check_watcher.data = check;
|
||||
@ -1082,6 +1088,7 @@ static void uv__idle(EV_P_ ev_idle* w, int revents) {
|
||||
|
||||
int uv_idle_init(uv_idle_t* idle) {
|
||||
uv__handle_init((uv_handle_t*)idle, UV_IDLE);
|
||||
uv_cnt_idle_init++;
|
||||
|
||||
ev_idle_init(&idle->idle_watcher, uv__idle);
|
||||
idle->idle_watcher.data = idle;
|
||||
@ -1150,6 +1157,7 @@ static void uv__async(EV_P_ ev_async* w, int revents) {
|
||||
|
||||
int uv_async_init(uv_async_t* async, uv_async_cb async_cb) {
|
||||
uv__handle_init((uv_handle_t*)async, UV_ASYNC);
|
||||
uv_cnt_async_init++;
|
||||
|
||||
ev_async_init(&async->async_watcher, uv__async);
|
||||
async->async_watcher.data = async;
|
||||
@ -1184,6 +1192,7 @@ static void uv__timer_cb(EV_P_ ev_timer* w, int revents) {
|
||||
|
||||
int uv_timer_init(uv_timer_t* timer) {
|
||||
uv__handle_init((uv_handle_t*)timer, UV_TIMER);
|
||||
uv_cnt_timer_init++;
|
||||
|
||||
ev_init(&timer->timer_watcher, uv__timer_cb);
|
||||
timer->timer_watcher.data = timer;
|
||||
|
||||
16
uv-win.c
16
uv-win.c
@ -410,6 +410,7 @@ void uv_init() {
|
||||
|
||||
|
||||
void uv_req_init(uv_req_t* req, uv_handle_t* handle, void* cb) {
|
||||
uv_cnt_req_init++;
|
||||
req->type = UV_UNKNOWN_REQ;
|
||||
req->flags = 0;
|
||||
req->handle = handle;
|
||||
@ -458,6 +459,9 @@ static uv_req_t* uv_remove_pending_req() {
|
||||
static int uv_tcp_init_socket(uv_tcp_t* handle, SOCKET socket) {
|
||||
DWORD yes = 1;
|
||||
|
||||
uv_cnt_handle_init++;
|
||||
uv_cnt_tcp_init++;
|
||||
|
||||
handle->socket = socket;
|
||||
handle->write_queue_size = 0;
|
||||
handle->type = UV_TCP;
|
||||
@ -1243,6 +1247,9 @@ RB_GENERATE_STATIC(uv_timer_tree_s, uv_timer_s, tree_entry, uv_timer_compare);
|
||||
|
||||
|
||||
int uv_timer_init(uv_timer_t* handle) {
|
||||
uv_cnt_handle_init++;
|
||||
uv_cnt_timer_init++;
|
||||
|
||||
handle->type = UV_TIMER;
|
||||
handle->flags = 0;
|
||||
handle->error = uv_ok_;
|
||||
@ -1415,18 +1422,24 @@ static void uv_loop_invoke(uv_handle_t* list) {
|
||||
|
||||
|
||||
int uv_prepare_init(uv_prepare_t* handle) {
|
||||
uv_cnt_handle_init++;
|
||||
uv_cnt_prepare_init++;
|
||||
handle->type = UV_PREPARE;
|
||||
return uv_loop_init((uv_handle_t*)handle);
|
||||
}
|
||||
|
||||
|
||||
int uv_check_init(uv_check_t* handle) {
|
||||
uv_cnt_handle_init++;
|
||||
uv_cnt_check_init++;
|
||||
handle->type = UV_CHECK;
|
||||
return uv_loop_init((uv_handle_t*)handle);
|
||||
}
|
||||
|
||||
|
||||
int uv_idle_init(uv_idle_t* handle) {
|
||||
uv_cnt_handle_init++;
|
||||
uv_cnt_idle_init++;
|
||||
handle->type = UV_IDLE;
|
||||
return uv_loop_init((uv_handle_t*)handle);
|
||||
}
|
||||
@ -1485,6 +1498,9 @@ int uv_is_active(uv_handle_t* handle) {
|
||||
int uv_async_init(uv_async_t* handle, uv_async_cb async_cb) {
|
||||
uv_req_t* req;
|
||||
|
||||
uv_cnt_handle_init++;
|
||||
uv_cnt_async_init++;
|
||||
|
||||
handle->type = UV_ASYNC;
|
||||
handle->flags = 0;
|
||||
handle->async_sent = 0;
|
||||
|
||||
10
uv.h
10
uv.h
@ -366,6 +366,16 @@ union uv_any_handle {
|
||||
uv_timer_t timer;
|
||||
};
|
||||
|
||||
/* Diagnostic counters */
|
||||
uint64_t uv_cnt_req_init;
|
||||
uint64_t uv_cnt_handle_init;
|
||||
uint64_t uv_cnt_tcp_init;
|
||||
uint64_t uv_cnt_prepare_init;
|
||||
uint64_t uv_cnt_check_init;
|
||||
uint64_t uv_cnt_idle_init;
|
||||
uint64_t uv_cnt_async_init;
|
||||
uint64_t uv_cnt_timer_init;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user