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); } }
static void uv__udp_stop_write_watcher(uv_udp_t* handle) { uv__udp_stop_watcher(handle, &handle->write_watcher); }
static void uv__udp_stop_read_watcher(uv_udp_t* handle) { uv__udp_stop_watcher(handle, &handle->read_watcher); }
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; }
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; }