Misc. cleanups
This commit is contained in:
parent
9c00849c9b
commit
5115d446c6
@ -172,6 +172,7 @@ TEST_IMPL(bind_error_inval) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(bind_localhost_ok) {
|
||||
struct sockaddr_in addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
|
||||
|
||||
@ -184,4 +185,6 @@ TEST_IMPL(bind_localhost_ok) {
|
||||
ASSERT(r == 0);
|
||||
r = uv_bind(&server, addr);
|
||||
ASSERT(r == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -49,6 +49,7 @@ TEST_DECLARE (fail_always)
|
||||
TEST_DECLARE (pass_always)
|
||||
HELPER_DECLARE (echo_server)
|
||||
|
||||
|
||||
TASK_LIST_START
|
||||
TEST_ENTRY (ping_pong)
|
||||
TEST_HELPER (ping_pong, echo_server)
|
||||
|
||||
58
uv-win.c
58
uv-win.c
@ -107,34 +107,26 @@
|
||||
|
||||
|
||||
/*
|
||||
* MinGw is missing this too
|
||||
* MinGW is missing this too
|
||||
*/
|
||||
#ifndef _MSC_VER
|
||||
typedef struct addrinfoW {
|
||||
int ai_flags;
|
||||
int ai_family;
|
||||
int ai_socktype;
|
||||
int ai_protocol;
|
||||
size_t ai_addrlen;
|
||||
wchar_t* ai_canonname;
|
||||
struct sockaddr* ai_addr;
|
||||
struct addrinfoW* ai_next;
|
||||
} ADDRINFOW, *PADDRINFOW;
|
||||
typedef struct addrinfoW {
|
||||
int ai_flags;
|
||||
int ai_family;
|
||||
int ai_socktype;
|
||||
int ai_protocol;
|
||||
size_t ai_addrlen;
|
||||
wchar_t* ai_canonname;
|
||||
struct sockaddr* ai_addr;
|
||||
struct addrinfoW* ai_next;
|
||||
} ADDRINFOW, *PADDRINFOW;
|
||||
|
||||
DECLSPEC_IMPORT int WSAAPI GetAddrInfoW(const wchar_t* node,
|
||||
const wchar_t* service,
|
||||
const ADDRINFOW* hints,
|
||||
PADDRINFOW* result);
|
||||
|
||||
DECLSPEC_IMPORT
|
||||
int
|
||||
WSAAPI
|
||||
GetAddrInfoW(const wchar_t* node,
|
||||
const wchar_t* service,
|
||||
const ADDRINFOW* hints,
|
||||
PADDRINFOW* result);
|
||||
|
||||
DECLSPEC_IMPORT
|
||||
void
|
||||
WSAAPI
|
||||
FreeAddrInfoW(PADDRINFOW pAddrInfo);
|
||||
|
||||
DECLSPEC_IMPORT void WSAAPI FreeAddrInfoW(PADDRINFOW pAddrInfo);
|
||||
#endif
|
||||
|
||||
|
||||
@ -1832,8 +1824,7 @@ void uv_remove_ares_handle(uv_ares_task_t* handle) {
|
||||
}
|
||||
|
||||
/* thread pool callback when socket is signalled */
|
||||
VOID CALLBACK uv_ares_socksignal_tp(PVOID parameter,
|
||||
BOOLEAN timerfired) {
|
||||
VOID CALLBACK uv_ares_socksignal_tp(void* parameter, BOOLEAN timerfired) {
|
||||
WSANETWORKEVENTS network_events;
|
||||
uv_ares_task_t* sockhandle;
|
||||
uv_ares_action_t* selhandle;
|
||||
@ -2014,6 +2005,8 @@ void uv_ares_task_cleanup(uv_ares_task_t* handle, uv_req_t* req) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* set ares SOCK_STATE callback to our handler */
|
||||
int uv_ares_init_options(ares_channel *channelptr,
|
||||
struct ares_options *options,
|
||||
@ -2041,6 +2034,7 @@ int uv_ares_init_options(ares_channel *channelptr,
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/* release memory */
|
||||
void uv_ares_destroy(ares_channel channel) {
|
||||
/* only allow destroy if did init */
|
||||
@ -2051,7 +2045,7 @@ void uv_ares_destroy(ares_channel channel) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
* getaddrinfo error code mapping
|
||||
* Falls back to uv_translate_sys_error if no match
|
||||
*/
|
||||
@ -2071,6 +2065,7 @@ static uv_err_code uv_translate_eai_error(int eai_errno) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* getaddrinfo worker thread implementation */
|
||||
static DWORD WINAPI getaddrinfo_thread_proc(void* parameter) {
|
||||
uv_getaddrinfo_t* handle = (uv_getaddrinfo_t*)parameter;
|
||||
@ -2095,7 +2090,8 @@ static DWORD WINAPI getaddrinfo_thread_proc(void* parameter) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Called from uv_run when complete. Call user specified callback
|
||||
* then free returned addrinfo
|
||||
* Returned addrinfo strings are converted from UTF-16 to UTF-8.
|
||||
@ -2211,8 +2207,9 @@ complete:
|
||||
uv_refs_--;
|
||||
}
|
||||
|
||||
/*
|
||||
* Entry point for getaddrinfo
|
||||
|
||||
/*
|
||||
* Entry point for getaddrinfo
|
||||
* we convert the UTF-8 strings to UNICODE
|
||||
* and save the UNICODE string pointers in the handle
|
||||
* We also copy hints so that caller does not need to keep memory until the callback.
|
||||
@ -2332,3 +2329,4 @@ error:
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
24
uv.h
24
uv.h
@ -81,7 +81,7 @@ typedef void (*uv_async_cb)(uv_async_t* handle, int status);
|
||||
typedef void (*uv_prepare_cb)(uv_prepare_t* handle, int status);
|
||||
typedef void (*uv_check_cb)(uv_check_t* handle, int status);
|
||||
typedef void (*uv_idle_cb)(uv_idle_t* handle, int status);
|
||||
typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* handle, int status, struct addrinfo *res);
|
||||
typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* handle, int status, struct addrinfo* res);
|
||||
|
||||
|
||||
/* Expand this list if necessary. */
|
||||
@ -410,8 +410,8 @@ struct uv_getaddrinfo_s {
|
||||
};
|
||||
|
||||
|
||||
/* uv_getaddrinfo
|
||||
* return code of UV_OK means that request is accepted,
|
||||
/* uv_getaddrinfo
|
||||
* return code of UV_OK means that request is accepted,
|
||||
* and callback will be called with result.
|
||||
* Other return codes mean that there will not be a callback.
|
||||
* Input arguments may be released after return from this call.
|
||||
@ -480,22 +480,24 @@ typedef struct {
|
||||
|
||||
uv_counters_t* uv_counters();
|
||||
|
||||
#ifndef SEC
|
||||
#define SEC 1
|
||||
|
||||
#ifndef SEC
|
||||
# define SEC 1
|
||||
#endif
|
||||
|
||||
#ifndef MILLISEC
|
||||
#define MILLISEC 1000
|
||||
#ifndef MILLISEC
|
||||
# define MILLISEC 1000
|
||||
#endif
|
||||
|
||||
#ifndef MICROSEC
|
||||
#define MICROSEC 1000000
|
||||
#ifndef MICROSEC
|
||||
# define MICROSEC 1000000
|
||||
#endif
|
||||
|
||||
#ifndef NANOSEC
|
||||
#define NANOSEC 1000000000
|
||||
#ifndef NANOSEC
|
||||
# define NANOSEC 1000000000
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Returns the current high-resolution real time. This is expressed in
|
||||
* nanoseconds. It is relative to an arbitrary time in the past. It is not
|
||||
|
||||
Loading…
Reference in New Issue
Block a user