示例#1
0
文件: uv-unix.c 项目: markuskopf/node
int uv_prepare_init(uv_prepare_t* prepare) {
  uv__handle_init((uv_handle_t*)prepare, UV_PREPARE);
  uv_counters()->prepare_init++;

  ev_prepare_init(&prepare->prepare_watcher, uv__prepare);
  prepare->prepare_watcher.data = prepare;

  prepare->prepare_cb = NULL;

  return 0;
}
示例#2
0
文件: uv-unix.c 项目: AMorgaut/node
int uv_idle_init(uv_idle_t* idle) {
  uv__handle_init((uv_handle_t*)idle, UV_IDLE);
  uv_counters()->idle_init++;

  ev_idle_init(&idle->idle_watcher, uv__idle);
  idle->idle_watcher.data = idle;

  idle->idle_cb = NULL;

  return 0;
}
示例#3
0
文件: uv-unix.c 项目: AMorgaut/node
int uv_check_init(uv_check_t* check) {
  uv__handle_init((uv_handle_t*)check, UV_CHECK);
  uv_counters()->check_init;

  ev_check_init(&check->check_watcher, uv__check);
  check->check_watcher.data = check;

  check->check_cb = NULL;

  return 0;
}
示例#4
0
文件: uv-unix.c 项目: markuskopf/node
static void uv__handle_init(uv_handle_t* handle, uv_handle_type type) {
  uv_counters()->handle_init++;

  handle->type = type;
  handle->flags = 0;

  ev_init(&handle->next_watcher, uv__next);
  handle->next_watcher.data = handle;

  /* Ref the loop until this handle is closed. See uv__finish_close. */
  ev_ref(EV_DEFAULT_UC);
}
示例#5
0
文件: pipe.c 项目: dakatsuka/node
int uv_pipe_init(uv_pipe_t* handle) {
  uv_stream_init((uv_stream_t*)handle);

  handle->type = UV_NAMED_PIPE;
  handle->reqs_pending = 0;
  handle->handle = INVALID_HANDLE_VALUE;
  handle->name = NULL;

  uv_counters()->pipe_init++;

  return 0;
}
示例#6
0
文件: tcp.c 项目: irca/libuv
int uv_tcp_init(uv_tcp_t* handle) {
  uv_stream_init((uv_stream_t*)handle);

  handle->accept_reqs = NULL;
  handle->pending_accepts = NULL;
  handle->socket = INVALID_SOCKET;
  handle->type = UV_TCP;
  handle->reqs_pending = 0;

  uv_counters()->tcp_init++;

  return 0;
}
示例#7
0
static void do_accept(uv_timer_t* timer_handle, int status) {
  uv_tcp_t* server;
  uv_tcp_t* accepted_handle = (uv_tcp_t*)malloc(sizeof *accepted_handle);
  uint64_t tcpcnt;
  int r;

  ASSERT(timer_handle != NULL);
  ASSERT(status == 0);
  ASSERT(accepted_handle != NULL);

  uv_tcp_init(accepted_handle);

  /* Test to that uv_counters()->tcp_init does not increase across the uv_accept. */
  tcpcnt = uv_counters()->tcp_init;

  server = (uv_tcp_t*)timer_handle->data;
  r = uv_accept((uv_handle_t*)server, (uv_stream_t*)accepted_handle);
  ASSERT(r == 0);

  ASSERT(uv_counters()->tcp_init == tcpcnt);

  do_accept_called++;

  /* Immediately close the accepted handle. */
  r = uv_close((uv_handle_t*)accepted_handle, close_cb);
  ASSERT(r == 0);

  /* After accepting the two clients close the server handle */
  if (do_accept_called == 2) {
    r = uv_close((uv_handle_t*)server, close_cb);
    ASSERT(r == 0);
  }

  /* Dispose the timer. */
  r = uv_close((uv_handle_t*)timer_handle, close_cb);
  ASSERT(r == 0);
}
示例#8
0
文件: uv-unix.c 项目: markuskopf/node
int uv_async_init(uv_async_t* async, uv_async_cb async_cb) {
  uv__handle_init((uv_handle_t*)async, UV_ASYNC);
  uv_counters()->async_init++;

  ev_async_init(&async->async_watcher, uv__async);
  async->async_watcher.data = async;

  async->async_cb = async_cb;

  /* Note: This does not have symmetry with the other libev wrappers. */
  ev_async_start(EV_DEFAULT_UC_ &async->async_watcher);
  ev_unref(EV_DEFAULT_UC);

  return 0;
}
示例#9
0
文件: uv-unix.c 项目: AMorgaut/node
int uv_tcp_init(uv_tcp_t* tcp) {
  uv__handle_init((uv_handle_t*)tcp, UV_TCP);
  uv_counters()->tcp_init++;

  tcp->alloc_cb = NULL;
  tcp->connect_req = NULL;
  tcp->accepted_fd = -1;
  tcp->fd = -1;
  tcp->delayed_error = 0;
  ngx_queue_init(&tcp->write_queue);
  tcp->write_queue_size = 0;

  ev_init(&tcp->read_watcher, uv__tcp_io);
  tcp->read_watcher.data = tcp;

  ev_init(&tcp->write_watcher, uv__tcp_io);
  tcp->write_watcher.data = tcp;

  assert(ngx_queue_empty(&tcp->write_queue));
  assert(tcp->write_queue_size == 0);

  return 0;
}
示例#10
0
文件: uv-unix.c 项目: markuskopf/node
void uv__req_init(uv_req_t* req) {
  uv_counters()->req_init++;
  req->type = UV_UNKNOWN_REQ;
  req->data = NULL;
}
示例#11
0
文件: req.c 项目: DagohtX/node
void uv_req_init(uv_req_t* req) {
  uv_counters()->req_init++;
  req->type = UV_UNKNOWN_REQ;
  req->error = uv_ok_;
}