Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: remove unnecessary functions in udp.c
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed May 23, 2012
1 parent 2b09cc2 commit 2609e43
Showing 1 changed file with 14 additions and 32 deletions.
46 changes: 14 additions & 32 deletions src/unix/udp.c
Expand Up @@ -61,35 +61,9 @@ static void uv__udp_stop_watcher(uv_udp_t* handle, uv__io_t* w) {
}


static void uv__udp_start_read_watcher(uv_udp_t* handle) {
uv__udp_start_watcher(handle,
&handle->read_watcher,
uv__udp_recvmsg,
UV__IO_READ);
}


static void uv__udp_start_write_watcher(uv_udp_t* handle) {
uv__udp_start_watcher(handle,
&handle->write_watcher,
uv__udp_sendmsg,
UV__IO_WRITE);
}


static void uv__udp_stop_read_watcher(uv_udp_t* handle) {
uv__udp_stop_watcher(handle, &handle->read_watcher);
}


static void uv__udp_stop_write_watcher(uv_udp_t* handle) {
uv__udp_stop_watcher(handle, &handle->write_watcher);
}


void uv__udp_close(uv_udp_t* handle) {
uv__udp_stop_write_watcher(handle);
uv__udp_stop_read_watcher(handle);
uv__udp_stop_watcher(handle, &handle->write_watcher);
uv__udp_stop_watcher(handle, &handle->read_watcher);
close(handle->fd);
handle->fd = -1;
}
Expand Down Expand Up @@ -298,7 +272,7 @@ static void uv__udp_sendmsg(uv_loop_t* loop, uv__io_t* w, int revents) {
}
else if (ngx_queue_empty(&handle->write_queue)) {
/* Pending queue and completion queue empty, stop watcher. */
uv__udp_stop_write_watcher(handle);
uv__udp_stop_watcher(handle, &handle->write_watcher);
}
}

Expand Down Expand Up @@ -457,7 +431,11 @@ static int uv__udp_send(uv_udp_send_t* req,
memcpy(req->bufs, bufs, bufcnt * sizeof(bufs[0]));

ngx_queue_insert_tail(&handle->write_queue, &req->queue);
uv__udp_start_write_watcher(handle);

uv__udp_start_watcher(handle,
&handle->write_watcher,
uv__udp_sendmsg,
UV__IO_WRITE);

return 0;
}
Expand Down Expand Up @@ -657,14 +635,18 @@ int uv_udp_recv_start(uv_udp_t* handle,

handle->alloc_cb = alloc_cb;
handle->recv_cb = recv_cb;
uv__udp_start_read_watcher(handle);

uv__udp_start_watcher(handle,
&handle->read_watcher,
uv__udp_recvmsg,
UV__IO_READ);

return 0;
}


int uv_udp_recv_stop(uv_udp_t* handle) {
uv__udp_stop_read_watcher(handle);
uv__udp_stop_watcher(handle, &handle->read_watcher);
handle->alloc_cb = NULL;
handle->recv_cb = NULL;
return 0;
Expand Down

0 comments on commit 2609e43

Please sign in to comment.