unix: clean up udp shutdown sequence
This commit is contained in:
parent
ee10cb77bd
commit
28b0867f03
@ -64,7 +64,6 @@ static void uv__finish_close(uv_handle_t* handle);
|
||||
|
||||
|
||||
void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
|
||||
uv_udp_t* udp;
|
||||
uv_async_t* async;
|
||||
uv_timer_t* timer;
|
||||
uv_stream_t* stream;
|
||||
@ -97,11 +96,7 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
|
||||
break;
|
||||
|
||||
case UV_UDP:
|
||||
udp = (uv_udp_t*)handle;
|
||||
uv__udp_watcher_stop(udp, &udp->read_watcher);
|
||||
uv__udp_watcher_stop(udp, &udp->write_watcher);
|
||||
uv__close(udp->fd);
|
||||
udp->fd = -1;
|
||||
uv__udp_start_close((uv_udp_t*)handle);
|
||||
break;
|
||||
|
||||
case UV_PREPARE:
|
||||
@ -278,10 +273,7 @@ void uv__finish_close(uv_handle_t* handle) {
|
||||
break;
|
||||
|
||||
case UV_UDP:
|
||||
assert(!ev_is_active(&((uv_udp_t*)handle)->read_watcher));
|
||||
assert(!ev_is_active(&((uv_udp_t*)handle)->write_watcher));
|
||||
assert(((uv_udp_t*)handle)->fd == -1);
|
||||
uv__udp_destroy((uv_udp_t*)handle);
|
||||
uv__udp_finish_close((uv_udp_t*)handle);
|
||||
break;
|
||||
|
||||
case UV_PROCESS:
|
||||
|
||||
@ -196,8 +196,8 @@ void uv__pipe_accept(EV_P_ ev_io* watcher, int revents);
|
||||
int uv_pipe_cleanup(uv_pipe_t* handle);
|
||||
|
||||
/* udp */
|
||||
void uv__udp_destroy(uv_udp_t* handle);
|
||||
void uv__udp_watcher_stop(uv_udp_t* handle, ev_io* w);
|
||||
void uv__udp_start_close(uv_udp_t* handle);
|
||||
void uv__udp_finish_close(uv_udp_t* handle);
|
||||
|
||||
/* fs */
|
||||
void uv__fs_event_destroy(uv_fs_event_t* handle);
|
||||
|
||||
@ -79,10 +79,22 @@ void uv__udp_watcher_stop(uv_udp_t* handle, ev_io* w) {
|
||||
}
|
||||
|
||||
|
||||
void uv__udp_destroy(uv_udp_t* handle) {
|
||||
void uv__udp_start_close(uv_udp_t* handle) {
|
||||
uv__udp_watcher_stop(handle, &handle->read_watcher);
|
||||
uv__udp_watcher_stop(handle, &handle->write_watcher);
|
||||
uv__close(handle->fd);
|
||||
handle->fd = -1;
|
||||
}
|
||||
|
||||
|
||||
void uv__udp_finish_close(uv_udp_t* handle) {
|
||||
uv_udp_send_t* req;
|
||||
ngx_queue_t* q;
|
||||
|
||||
assert(!ev_is_active(&handle->write_watcher));
|
||||
assert(!ev_is_active(&handle->read_watcher));
|
||||
assert(handle->fd == -1);
|
||||
|
||||
uv__udp_run_completed(handle);
|
||||
|
||||
while (!ngx_queue_empty(&handle->write_queue)) {
|
||||
@ -102,14 +114,6 @@ void uv__udp_destroy(uv_udp_t* handle) {
|
||||
handle->recv_cb = NULL;
|
||||
handle->alloc_cb = NULL;
|
||||
/* but _do not_ touch close_cb */
|
||||
|
||||
if (handle->fd != -1) {
|
||||
uv__close(handle->fd);
|
||||
handle->fd = -1;
|
||||
}
|
||||
|
||||
uv__udp_watcher_stop(handle, &handle->read_watcher);
|
||||
uv__udp_watcher_stop(handle, &handle->write_watcher);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user