diff options
Diffstat (limited to 'Utilities/cmlibuv/src/win/udp.c')
-rw-r--r-- | Utilities/cmlibuv/src/win/udp.c | 103 |
1 files changed, 52 insertions, 51 deletions
diff --git a/Utilities/cmlibuv/src/win/udp.c b/Utilities/cmlibuv/src/win/udp.c index 7b5efa2..eaebc1e 100644 --- a/Utilities/cmlibuv/src/win/udp.c +++ b/Utilities/cmlibuv/src/win/udp.c @@ -60,7 +60,7 @@ int uv_udp_getsockname(const uv_udp_t* handle, } -static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle, SOCKET socket, +static int uv__udp_set_socket(uv_loop_t* loop, uv_udp_t* handle, SOCKET socket, int family) { DWORD yes = 1; WSAPROTOCOL_INFOW info; @@ -106,8 +106,8 @@ static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle, SOCKET socket, FILE_SKIP_SET_EVENT_ON_HANDLE | FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) { handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP; - handle->func_wsarecv = uv_wsarecv_workaround; - handle->func_wsarecvfrom = uv_wsarecvfrom_workaround; + handle->func_wsarecv = uv__wsarecv_workaround; + handle->func_wsarecvfrom = uv__wsarecvfrom_workaround; } else if (GetLastError() != ERROR_INVALID_FUNCTION) { return GetLastError(); } @@ -155,7 +155,7 @@ int uv__udp_init_ex(uv_loop_t* loop, return uv_translate_sys_error(err); } - err = uv_udp_set_socket(handle->loop, handle, sock, domain); + err = uv__udp_set_socket(handle->loop, handle, sock, domain); if (err) { closesocket(sock); QUEUE_REMOVE(&handle->handle_queue); @@ -167,7 +167,7 @@ int uv__udp_init_ex(uv_loop_t* loop, } -void uv_udp_close(uv_loop_t* loop, uv_udp_t* handle) { +void uv__udp_close(uv_loop_t* loop, uv_udp_t* handle) { uv_udp_recv_stop(handle); closesocket(handle->socket); handle->socket = INVALID_SOCKET; @@ -175,12 +175,12 @@ void uv_udp_close(uv_loop_t* loop, uv_udp_t* handle) { uv__handle_closing(handle); if (handle->reqs_pending == 0) { - uv_want_endgame(loop, (uv_handle_t*) handle); + uv__want_endgame(loop, (uv_handle_t*) handle); } } -void uv_udp_endgame(uv_loop_t* loop, uv_udp_t* handle) { +void uv__udp_endgame(uv_loop_t* loop, uv_udp_t* handle) { if (handle->flags & UV_HANDLE_CLOSING && handle->reqs_pending == 0) { assert(!(handle->flags & UV_HANDLE_CLOSED)); @@ -194,10 +194,10 @@ int uv_udp_using_recvmmsg(const uv_udp_t* handle) { } -static int uv_udp_maybe_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int addrlen, - unsigned int flags) { +static int uv__udp_maybe_bind(uv_udp_t* handle, + const struct sockaddr* addr, + unsigned int addrlen, + unsigned int flags) { int r; int err; DWORD no = 0; @@ -216,7 +216,7 @@ static int uv_udp_maybe_bind(uv_udp_t* handle, return WSAGetLastError(); } - err = uv_udp_set_socket(handle->loop, handle, sock, addr->sa_family); + err = uv__udp_set_socket(handle->loop, handle, sock, addr->sa_family); if (err) { closesocket(sock); return err; @@ -264,7 +264,7 @@ static int uv_udp_maybe_bind(uv_udp_t* handle, } -static void uv_udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) { +static void uv__udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) { uv_req_t* req; uv_buf_t buf; DWORD bytes, flags; @@ -311,7 +311,7 @@ static void uv_udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) { handle->flags |= UV_HANDLE_READ_PENDING; req->u.io.overlapped.InternalHigh = bytes; handle->reqs_pending++; - uv_insert_pending_req(loop, req); + uv__insert_pending_req(loop, req); } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { /* The req will be processed with IOCP. */ handle->flags |= UV_HANDLE_READ_PENDING; @@ -319,7 +319,7 @@ static void uv_udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) { } else { /* Make this req pending reporting an error. */ SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, req); + uv__insert_pending_req(loop, req); handle->reqs_pending++; } @@ -343,7 +343,7 @@ static void uv_udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) { handle->flags |= UV_HANDLE_READ_PENDING; req->u.io.overlapped.InternalHigh = bytes; handle->reqs_pending++; - uv_insert_pending_req(loop, req); + uv__insert_pending_req(loop, req); } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { /* The req will be processed with IOCP. */ handle->flags |= UV_HANDLE_READ_PENDING; @@ -351,7 +351,7 @@ static void uv_udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) { } else { /* Make this req pending reporting an error. */ SET_REQ_ERROR(req, WSAGetLastError()); - uv_insert_pending_req(loop, req); + uv__insert_pending_req(loop, req); handle->reqs_pending++; } } @@ -367,10 +367,10 @@ int uv__udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, return UV_EALREADY; } - err = uv_udp_maybe_bind(handle, - (const struct sockaddr*) &uv_addr_ip4_any_, - sizeof(uv_addr_ip4_any_), - 0); + err = uv__udp_maybe_bind(handle, + (const struct sockaddr*) &uv_addr_ip4_any_, + sizeof(uv_addr_ip4_any_), + 0); if (err) return uv_translate_sys_error(err); @@ -384,7 +384,7 @@ int uv__udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, /* If reading was stopped and then started again, there could still be a recv * request pending. */ if (!(handle->flags & UV_HANDLE_READ_PENDING)) - uv_udp_queue_recv(loop, handle); + uv__udp_queue_recv(loop, handle); return 0; } @@ -433,7 +433,7 @@ static int uv__send(uv_udp_send_t* req, handle->send_queue_size += req->u.io.queued_bytes; handle->send_queue_count++; REGISTER_HANDLE_REQ(loop, handle, req); - uv_insert_pending_req(loop, (uv_req_t*)req); + uv__insert_pending_req(loop, (uv_req_t*)req); } else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) { /* Request queued by the kernel. */ req->u.io.queued_bytes = uv__count_bufs(bufs, nbufs); @@ -450,7 +450,7 @@ static int uv__send(uv_udp_send_t* req, } -void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, +void uv__process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, uv_req_t* req) { uv_buf_t buf; int partial; @@ -554,14 +554,14 @@ done: /* Post another read if still reading and not closing. */ if ((handle->flags & UV_HANDLE_READING) && !(handle->flags & UV_HANDLE_READ_PENDING)) { - uv_udp_queue_recv(loop, handle); + uv__udp_queue_recv(loop, handle); } DECREASE_PENDING_REQ_COUNT(handle); } -void uv_process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle, +void uv__process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle, uv_udp_send_t* req) { int err; @@ -598,10 +598,10 @@ static int uv__udp_set_membership4(uv_udp_t* handle, return UV_EINVAL; /* If the socket is unbound, bind to inaddr_any. */ - err = uv_udp_maybe_bind(handle, - (const struct sockaddr*) &uv_addr_ip4_any_, - sizeof(uv_addr_ip4_any_), - UV_UDP_REUSEADDR); + err = uv__udp_maybe_bind(handle, + (const struct sockaddr*) &uv_addr_ip4_any_, + sizeof(uv_addr_ip4_any_), + UV_UDP_REUSEADDR); if (err) return uv_translate_sys_error(err); @@ -652,10 +652,10 @@ int uv__udp_set_membership6(uv_udp_t* handle, if ((handle->flags & UV_HANDLE_BOUND) && !(handle->flags & UV_HANDLE_IPV6)) return UV_EINVAL; - err = uv_udp_maybe_bind(handle, - (const struct sockaddr*) &uv_addr_ip6_any_, - sizeof(uv_addr_ip6_any_), - UV_UDP_REUSEADDR); + err = uv__udp_maybe_bind(handle, + (const struct sockaddr*) &uv_addr_ip6_any_, + sizeof(uv_addr_ip6_any_), + UV_UDP_REUSEADDR); if (err) return uv_translate_sys_error(err); @@ -708,10 +708,10 @@ static int uv__udp_set_source_membership4(uv_udp_t* handle, return UV_EINVAL; /* If the socket is unbound, bind to inaddr_any. */ - err = uv_udp_maybe_bind(handle, - (const struct sockaddr*) &uv_addr_ip4_any_, - sizeof(uv_addr_ip4_any_), - UV_UDP_REUSEADDR); + err = uv__udp_maybe_bind(handle, + (const struct sockaddr*) &uv_addr_ip4_any_, + sizeof(uv_addr_ip4_any_), + UV_UDP_REUSEADDR); if (err) return uv_translate_sys_error(err); @@ -763,10 +763,10 @@ int uv__udp_set_source_membership6(uv_udp_t* handle, if ((handle->flags & UV_HANDLE_BOUND) && !(handle->flags & UV_HANDLE_IPV6)) return UV_EINVAL; - err = uv_udp_maybe_bind(handle, - (const struct sockaddr*) &uv_addr_ip6_any_, - sizeof(uv_addr_ip6_any_), - UV_UDP_REUSEADDR); + err = uv__udp_maybe_bind(handle, + (const struct sockaddr*) &uv_addr_ip6_any_, + sizeof(uv_addr_ip6_any_), + UV_UDP_REUSEADDR); if (err) return uv_translate_sys_error(err); @@ -962,10 +962,10 @@ int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) { return uv_translate_sys_error(GetLastError()); } - err = uv_udp_set_socket(handle->loop, - handle, - sock, - protocol_info.iAddressFamily); + err = uv__udp_set_socket(handle->loop, + handle, + sock, + protocol_info.iAddressFamily); if (err) return uv_translate_sys_error(err); @@ -1044,7 +1044,7 @@ int uv__udp_bind(uv_udp_t* handle, unsigned int flags) { int err; - err = uv_udp_maybe_bind(handle, addr, addrlen, flags); + err = uv__udp_maybe_bind(handle, addr, addrlen, flags); if (err) return uv_translate_sys_error(err); @@ -1066,7 +1066,7 @@ int uv__udp_connect(uv_udp_t* handle, else return UV_EINVAL; - err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0); + err = uv__udp_maybe_bind(handle, bind_addr, addrlen, 0); if (err) return uv_translate_sys_error(err); } @@ -1117,7 +1117,7 @@ int uv__udp_send(uv_udp_send_t* req, else return UV_EINVAL; - err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0); + err = uv__udp_maybe_bind(handle, bind_addr, addrlen, 0); if (err) return uv_translate_sys_error(err); } @@ -1146,6 +1146,7 @@ int uv__udp_try_send(uv_udp_t* handle, err = uv__convert_to_localhost_if_unspecified(addr, &converted); if (err) return err; + addr = (const struct sockaddr*) &converted; } /* Already sending a message.*/ @@ -1159,7 +1160,7 @@ int uv__udp_try_send(uv_udp_t* handle, bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_; else return UV_EINVAL; - err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0); + err = uv__udp_maybe_bind(handle, bind_addr, addrlen, 0); if (err) return uv_translate_sys_error(err); } @@ -1169,7 +1170,7 @@ int uv__udp_try_send(uv_udp_t* handle, nbufs, &bytes, 0, - (const struct sockaddr*) &converted, + addr, addrlen, NULL, NULL); |