static int stop_check (lua_State *L) { int ret = 0; libuv_check_t *check = NULL; TRACE("arguments: L = %p\n", L); assert(L != NULL); /* [ userdata ] */ assert(lua_gettop(L) == 1); /* get self argument */ check = (libuv_check_t *)luaL_checkudata(L, 1, CHECK_T); TRACE("get libuv_check_t (%p)\n", check); assert(check != NULL); assert(check->uvcheck != NULL); /* execute uv_check_stop */ ret = uv_check_stop(check->uvcheck); TRACE("uv_check_stop: ret = %d\n", ret); /* set reference */ TRACE("unreference uv_check_t\n"); luaL_unref(L, LUA_REGISTRYINDEX, check->ref); check->ref = LUA_NOREF; TRACE("libuv_check_t attributes: uvcheck = %p, L = %p, ref = 0x%012x\n", check->uvcheck, check->L, check->ref); /* set return */ lua_pushinteger(L, ret); /* [ userdata, number ] */ return 1; }
static int luv_check_stop(lua_State* L) { uv_check_t* handle = luv_check_check(L, 1); int ret = uv_check_stop(handle); if (ret < 0) return luv_error(L, ret); lua_pushinteger(L, ret); return 1; }
/* * Class: com_oracle_libuv_handles_CheckHandle * Method: _stop * Signature: (J)I */ JNIEXPORT jint JNICALL Java_com_oracle_libuv_handles_CheckHandle__1stop (JNIEnv *env, jobject that, jlong check) { assert(check); uv_check_t* handle = reinterpret_cast<uv_check_t*>(check); int r = uv_check_stop(handle); if (r) { ThrowException(env, handle->loop, "uv_check_stop"); } return r; }
int uv_close(uv_handle_t* handle, uv_close_cb close_cb) { uv_tcp_t* tcp; uv_async_t* async; uv_timer_t* timer; handle->close_cb = close_cb; switch (handle->type) { case UV_TCP: tcp = (uv_tcp_t*) handle; uv_read_stop((uv_stream_t*)tcp); ev_io_stop(EV_DEFAULT_ &tcp->write_watcher); break; case UV_PREPARE: uv_prepare_stop((uv_prepare_t*) handle); break; case UV_CHECK: uv_check_stop((uv_check_t*) handle); break; case UV_IDLE: uv_idle_stop((uv_idle_t*) handle); break; case UV_ASYNC: async = (uv_async_t*)handle; ev_async_stop(EV_DEFAULT_ &async->async_watcher); ev_ref(EV_DEFAULT_UC); break; case UV_TIMER: timer = (uv_timer_t*)handle; if (ev_is_active(&timer->timer_watcher)) { ev_ref(EV_DEFAULT_UC); } ev_timer_stop(EV_DEFAULT_ &timer->timer_watcher); break; default: assert(0); return -1; } uv_flag_set(handle, UV_CLOSING); /* This is used to call the on_close callback in the next loop. */ ev_idle_start(EV_DEFAULT_ &handle->next_watcher); ev_feed_event(EV_DEFAULT_ &handle->next_watcher, EV_IDLE); assert(ev_is_pending(&handle->next_watcher)); return 0; }
CAMLprim value camluv_check_stop(value check) { CAMLparam1(check); CAMLlocal1(camluv_rc); int rc = -1; camluv_check_t *camluv_check = camluv_check_struct_val(check); rc = uv_check_stop(&(camluv_check->uv_check)); camluv_rc = camluv_errno_c2ml(rc); CAMLreturn(camluv_rc); }
int uv_close(uv_handle_t* handle) { switch (handle->type) { case UV_TCP: ev_io_stop(EV_DEFAULT_ &handle->write_watcher); ev_io_stop(EV_DEFAULT_ &handle->read_watcher); break; case UV_PREPARE: uv_prepare_stop(handle); break; case UV_CHECK: uv_check_stop(handle); break; case UV_IDLE: uv_idle_stop(handle); break; case UV_ASYNC: ev_async_stop(EV_DEFAULT_ &handle->async_watcher); ev_ref(EV_DEFAULT_UC); break; case UV_TIMER: if (ev_is_active(&handle->timer_watcher)) { ev_ref(EV_DEFAULT_UC); } ev_timer_stop(EV_DEFAULT_ &handle->timer_watcher); break; default: assert(0); return -1; } uv_flag_set(handle, UV_CLOSING); /* This is used to call the on_close callback in the next loop. */ ev_idle_start(EV_DEFAULT_ &handle->next_watcher); ev_feed_event(EV_DEFAULT_ &handle->next_watcher, EV_IDLE); assert(ev_is_pending(&handle->next_watcher)); return 0; }
static PyObject * Check_func_stop(Check *self) { int r; RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL); RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL); r = uv_check_stop((uv_check_t *)UV_HANDLE(self)); if (r != 0) { RAISE_UV_EXCEPTION(UV_HANDLE_LOOP(self), PyExc_CheckError); return NULL; } Py_XDECREF(self->callback); self->callback = NULL; Py_RETURN_NONE; }
/* u2_unix_io_exit(): terminate unix I/O. */ void u2_unix_io_exit(void) { uv_check_stop(&u2_Host.unx_u.syn_u); u2_unix_release(u2_Host.cpu_c); { u2_uhot* hot_u; for ( hot_u = u2_Host.unx_u.hot_u; hot_u; hot_u = hot_u->nex_u ) { u2_unix_release(hot_u->dir_u.pax_c); } } #ifdef SYNCLOG for (int i = 0; i<1024; i++) { free(u2_Host.unx_u.sylo[i].pax_c); } #endif }
static PyObject * Check_func_stop(Check *self) { int err; RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL); RAISE_IF_HANDLE_CLOSED(self, PyExc_HandleClosedError, NULL); err = uv_check_stop(&self->check_h); if (err < 0) { RAISE_UV_EXCEPTION(err, PyExc_CheckError); return NULL; } Py_XDECREF(self->callback); self->callback = NULL; PYUV_HANDLE_DECREF(self); Py_RETURN_NONE; }
void uv_close(uv_handle_t* handle, uv_close_cb close_cb) { uv_async_t* async; uv_stream_t* stream; uv_process_t* process; handle->close_cb = close_cb; switch (handle->type) { case UV_NAMED_PIPE: uv_pipe_cleanup((uv_pipe_t*)handle); /* Fall through. */ case UV_TTY: case UV_TCP: stream = (uv_stream_t*)handle; uv_read_stop(stream); ev_io_stop(stream->loop->ev, &stream->write_watcher); uv__close(stream->fd); stream->fd = -1; if (stream->accepted_fd >= 0) { uv__close(stream->accepted_fd); stream->accepted_fd = -1; } assert(!ev_is_active(&stream->read_watcher)); assert(!ev_is_active(&stream->write_watcher)); break; case UV_UDP: uv__udp_start_close((uv_udp_t*)handle); break; case UV_PREPARE: uv_prepare_stop((uv_prepare_t*) handle); break; case UV_CHECK: uv_check_stop((uv_check_t*) handle); break; case UV_IDLE: uv_idle_stop((uv_idle_t*) handle); break; case UV_ASYNC: async = (uv_async_t*)handle; ev_async_stop(async->loop->ev, &async->async_watcher); ev_ref(async->loop->ev); break; case UV_TIMER: uv_timer_stop((uv_timer_t*)handle); break; case UV_PROCESS: process = (uv_process_t*)handle; ev_child_stop(process->loop->ev, &process->child_watcher); break; case UV_FS_EVENT: uv__fs_event_destroy((uv_fs_event_t*)handle); break; default: assert(0); } handle->flags |= UV_CLOSING; /* This is used to call the on_close callback in the next loop. */ ev_idle_start(handle->loop->ev, &handle->next_watcher); ev_feed_event(handle->loop->ev, &handle->next_watcher, EV_IDLE); assert(ev_is_pending(&handle->next_watcher)); }
void uv_close(uv_handle_t* handle, uv_close_cb cb) { uv_loop_t* loop = handle->loop; if (handle->flags & UV__HANDLE_CLOSING) { assert(0); return; } handle->close_cb = cb; /* Handle-specific close actions */ switch (handle->type) { case UV_TCP: uv_tcp_close(loop, (uv_tcp_t*)handle); return; case UV_NAMED_PIPE: uv_pipe_close(loop, (uv_pipe_t*) handle); return; case UV_TTY: uv_tty_close((uv_tty_t*) handle); return; case UV_UDP: uv_udp_close(loop, (uv_udp_t*) handle); return; case UV_POLL: uv_poll_close(loop, (uv_poll_t*) handle); return; case UV_TIMER: uv_timer_stop((uv_timer_t*)handle); uv__handle_closing(handle); uv_want_endgame(loop, handle); return; case UV_PREPARE: uv_prepare_stop((uv_prepare_t*)handle); uv__handle_closing(handle); uv_want_endgame(loop, handle); return; case UV_CHECK: uv_check_stop((uv_check_t*)handle); uv__handle_closing(handle); uv_want_endgame(loop, handle); return; case UV_IDLE: uv_idle_stop((uv_idle_t*)handle); uv__handle_closing(handle); uv_want_endgame(loop, handle); return; case UV_ASYNC: uv_async_close(loop, (uv_async_t*) handle); return; case UV_SIGNAL: uv_signal_close(loop, (uv_signal_t*) handle); return; case UV_PROCESS: uv_process_close(loop, (uv_process_t*) handle); return; case UV_FS_EVENT: uv_fs_event_close(loop, (uv_fs_event_t*) handle); return; case UV_FS_POLL: uv__fs_poll_close((uv_fs_poll_t*) handle); uv__handle_closing(handle); uv_want_endgame(loop, handle); return; default: /* Not supported */ abort(); } }
/* TODO: integrate this with uv_close. */ static void uv_close_error(uv_handle_t* handle, uv_err_t e) { uv_tcp_t* tcp; uv_pipe_t* pipe; if (handle->flags & UV_HANDLE_CLOSING) { return; } handle->error = e; handle->flags |= UV_HANDLE_CLOSING; /* Handle-specific close actions */ switch (handle->type) { case UV_TCP: tcp = (uv_tcp_t*)handle; /* If we don't shutdown before calling closesocket, windows will */ /* silently discard the kernel send buffer and reset the connection. */ if (!(tcp->flags & UV_HANDLE_SHUT)) { shutdown(tcp->socket, SD_SEND); tcp->flags |= UV_HANDLE_SHUT; } tcp->flags &= ~(UV_HANDLE_READING | UV_HANDLE_LISTENING); closesocket(tcp->socket); if (tcp->reqs_pending == 0) { uv_want_endgame(handle); } return; case UV_NAMED_PIPE: pipe = (uv_pipe_t*)handle; pipe->flags &= ~(UV_HANDLE_READING | UV_HANDLE_LISTENING); close_pipe(pipe, NULL, NULL); if (pipe->reqs_pending == 0) { uv_want_endgame(handle); } return; case UV_TIMER: uv_timer_stop((uv_timer_t*)handle); uv_want_endgame(handle); return; case UV_PREPARE: uv_prepare_stop((uv_prepare_t*)handle); uv_want_endgame(handle); return; case UV_CHECK: uv_check_stop((uv_check_t*)handle); uv_want_endgame(handle); return; case UV_IDLE: uv_idle_stop((uv_idle_t*)handle); uv_want_endgame(handle); return; case UV_ASYNC: if (!((uv_async_t*)handle)->async_sent) { uv_want_endgame(handle); } return; default: /* Not supported */ abort(); } }
/* u3_unix_io_exit(): terminate unix I/O. */ void u3_unix_io_exit(void) { uv_check_stop(&u3_Host.unx_u.syn_u); u3_unix_release(u3_Host.dir_c); }
void uv_close(uv_handle_t* handle, uv_close_cb cb) { uv_pipe_t* pipe; uv_udp_t* udp; uv_process_t* process; uv_loop_t* loop = handle->loop; if (handle->flags & UV_HANDLE_CLOSING) { return; } handle->flags |= UV_HANDLE_CLOSING; handle->close_cb = cb; /* Handle-specific close actions */ switch (handle->type) { case UV_TCP: uv_tcp_close((uv_tcp_t*)handle); return; case UV_NAMED_PIPE: pipe = (uv_pipe_t*)handle; pipe->flags &= ~(UV_HANDLE_READING | UV_HANDLE_LISTENING); close_pipe(pipe, NULL, NULL); if (pipe->reqs_pending == 0) { uv_want_endgame(loop, handle); } return; case UV_TTY: uv_tty_close((uv_tty_t*) handle); return; case UV_UDP: udp = (uv_udp_t*) handle; uv_udp_recv_stop(udp); closesocket(udp->socket); if (udp->reqs_pending == 0) { uv_want_endgame(loop, handle); } return; case UV_POLL: uv_poll_close(handle->loop, (uv_poll_t*) handle); return; case UV_TIMER: uv_timer_stop((uv_timer_t*)handle); uv_want_endgame(loop, handle); return; case UV_PREPARE: uv_prepare_stop((uv_prepare_t*)handle); uv_want_endgame(loop, handle); return; case UV_CHECK: uv_check_stop((uv_check_t*)handle); uv_want_endgame(loop, handle); return; case UV_IDLE: uv_idle_stop((uv_idle_t*)handle); uv_want_endgame(loop, handle); return; case UV_ASYNC: if (!((uv_async_t*)handle)->async_sent) { uv_want_endgame(loop, handle); } return; case UV_PROCESS: process = (uv_process_t*)handle; uv_process_close(loop, process); return; case UV_FS_EVENT: uv_fs_event_close(loop, (uv_fs_event_t*)handle); return; default: /* Not supported */ abort(); } }