コード例 #1
0
ファイル: udp.c プロジェクト: wynnw/libuv
static void uv__udp_sendmsg(uv_loop_t* loop, uv__io_t* w, int revents) {
  uv_udp_t* handle;

  handle = container_of(w, uv_udp_t, write_watcher);
  assert(handle->type == UV_UDP);
  assert(revents & UV__IO_WRITE);

  assert(!ngx_queue_empty(&handle->write_queue)
      || !ngx_queue_empty(&handle->write_completed_queue));

  /* Write out pending data first. */
  uv__udp_run_pending(handle);

  /* Drain 'request completed' queue. */
  uv__udp_run_completed(handle);

  if (!ngx_queue_empty(&handle->write_completed_queue)) {
    /* Schedule completion callbacks. */
    uv__io_feed(handle->loop, &handle->write_watcher, UV__IO_WRITE);
  }
  else if (ngx_queue_empty(&handle->write_queue)) {
    /* Pending queue and completion queue empty, stop watcher. */
    uv__udp_stop_watcher(handle, &handle->write_watcher);
  }
}
コード例 #2
0
ファイル: udp.c プロジェクト: nuxleus/libuv
static void uv__udp_stop_write_watcher(uv_udp_t* handle) {
  uv__udp_stop_watcher(handle, &handle->write_watcher);
}
コード例 #3
0
ファイル: udp.c プロジェクト: nuxleus/libuv
static void uv__udp_stop_read_watcher(uv_udp_t* handle) {
  uv__udp_stop_watcher(handle, &handle->read_watcher);
}
コード例 #4
0
ファイル: udp.c プロジェクト: wynnw/libuv
int uv_udp_recv_stop(uv_udp_t* handle) {
  uv__udp_stop_watcher(handle, &handle->read_watcher);
  handle->alloc_cb = NULL;
  handle->recv_cb = NULL;
  return 0;
}
コード例 #5
0
ファイル: udp.c プロジェクト: wynnw/libuv
void uv__udp_close(uv_udp_t* handle) {
  uv__udp_stop_watcher(handle, &handle->write_watcher);
  uv__udp_stop_watcher(handle, &handle->read_watcher);
  close(handle->fd);
  handle->fd = -1;
}