fix windows build
This commit is contained in:
parent
23796d208c
commit
e7a53aed48
@ -75,9 +75,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
|
||||
uv_idle_t* next_idle_handle; \
|
||||
ares_channel ares_chan; \
|
||||
int ares_active_sockets; \
|
||||
uv_timer_t ares_polling_timer; \
|
||||
/* Last error code */ \
|
||||
uv_err_t last_error;
|
||||
uv_timer_t ares_polling_timer;
|
||||
|
||||
#define UV_REQ_TYPE_PRIVATE \
|
||||
/* TODO: remove the req suffix */ \
|
||||
|
||||
@ -56,11 +56,6 @@ void uv_fatal_error(const int errorno, const char* syscall) {
|
||||
}
|
||||
|
||||
|
||||
uv_err_t uv_last_error(uv_loop_t* loop) {
|
||||
return loop->last_err;
|
||||
}
|
||||
|
||||
|
||||
char* uv_strerror(uv_err_t err) {
|
||||
return strerror(err.sys_errno_);
|
||||
}
|
||||
|
||||
@ -113,6 +113,11 @@ void uv__set_artificial_error(uv_loop_t* loop, uv_err_code code) {
|
||||
}
|
||||
|
||||
|
||||
uv_err_t uv_last_error(uv_loop_t* loop) {
|
||||
return loop->last_err;
|
||||
}
|
||||
|
||||
|
||||
struct sockaddr_in uv_ip4_addr(const char* ip, int port) {
|
||||
struct sockaddr_in addr;
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ static void uv_loop_init(uv_loop_t* loop) {
|
||||
loop->ares_active_sockets = 0;
|
||||
loop->ares_chan = NULL;
|
||||
|
||||
loop->last_error = uv_ok_;
|
||||
loop->last_err = uv_ok_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -67,11 +67,6 @@ void uv_fatal_error(const int errorno, const char* syscall) {
|
||||
}
|
||||
|
||||
|
||||
uv_err_t uv_last_error(uv_loop_t* loop) {
|
||||
return loop->last_error;
|
||||
}
|
||||
|
||||
|
||||
/* TODO: thread safety */
|
||||
static char* last_err_str_ = NULL;
|
||||
|
||||
@ -136,10 +131,3 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uv_err_t uv_new_sys_error(int sys_errno) {
|
||||
uv_err_t e;
|
||||
e.code = uv_translate_sys_error(sys_errno);
|
||||
e.sys_errno_ = sys_errno;
|
||||
return e;
|
||||
}
|
||||
|
||||
@ -330,7 +330,7 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
|
||||
handle->cb(handle, NULL, UV_CHANGE, 0);
|
||||
}
|
||||
} else {
|
||||
loop->last_error = GET_REQ_UV_ERROR(req);
|
||||
uv__set_sys_error(loop, GET_REQ_ERROR(req));
|
||||
handle->cb(handle, NULL, 0, -1);
|
||||
}
|
||||
|
||||
|
||||
@ -297,12 +297,6 @@ uv_err_code uv_translate_sys_error(int sys_errno);
|
||||
#define GET_REQ_SOCK_ERROR(req) \
|
||||
(uv_ntstatus_to_winsock_error(GET_REQ_STATUS((req))))
|
||||
|
||||
#define GET_REQ_UV_ERROR(req) \
|
||||
(uv_new_sys_error(GET_REQ_ERROR((req))))
|
||||
|
||||
#define GET_REQ_UV_SOCK_ERROR(req) \
|
||||
(uv_new_sys_error(GET_REQ_SOCK_ERROR((req))))
|
||||
|
||||
|
||||
/*
|
||||
* Initialization for the windows and winsock api
|
||||
|
||||
@ -891,7 +891,7 @@ void uv_process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle,
|
||||
|
||||
if (req->cb) {
|
||||
if (!REQ_SUCCESS(req)) {
|
||||
loop->last_error = GET_REQ_UV_ERROR(req);
|
||||
uv__set_sys_error(loop, GET_REQ_ERROR(req));
|
||||
((uv_write_cb)req->cb)(req, -1);
|
||||
} else {
|
||||
((uv_write_cb)req->cb)(req, 0);
|
||||
@ -946,7 +946,7 @@ void uv_process_pipe_connect_req(uv_loop_t* loop, uv_pipe_t* handle,
|
||||
uv_pipe_connection_init(handle);
|
||||
((uv_connect_cb)req->cb)(req, 0);
|
||||
} else {
|
||||
loop->last_error = GET_REQ_UV_ERROR(req);
|
||||
uv__set_sys_error(loop, GET_REQ_ERROR(req));
|
||||
((uv_connect_cb)req->cb)(req, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) {
|
||||
}
|
||||
if (handle->shutdown_req->cb) {
|
||||
if (status == -1) {
|
||||
uv__set_sys_error(sys_error);
|
||||
uv__set_sys_error(loop, sys_error);
|
||||
}
|
||||
handle->shutdown_req->cb(handle->shutdown_req, status);
|
||||
}
|
||||
@ -356,7 +356,7 @@ int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) {
|
||||
assert(backlog > 0);
|
||||
|
||||
if (handle->flags & UV_HANDLE_BIND_ERROR) {
|
||||
uv__set_sys_error(handle->bind_error);
|
||||
uv__set_sys_error(loop, handle->bind_error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -480,7 +480,7 @@ int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle,
|
||||
DWORD bytes;
|
||||
|
||||
if (handle->flags & UV_HANDLE_BIND_ERROR) {
|
||||
uv__set_sys_error(handle->bind_error);
|
||||
uv__set_sys_error(loop, handle->bind_error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -531,12 +531,12 @@ int uv_tcp_connect6(uv_connect_t* req, uv_tcp_t* handle,
|
||||
DWORD bytes;
|
||||
|
||||
if (!uv_allow_ipv6) {
|
||||
uv_new_sys_error(WSAEAFNOSUPPORT);
|
||||
uv__set_sys_error(loop, WSAEAFNOSUPPORT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (handle->flags & UV_HANDLE_BIND_ERROR) {
|
||||
uv__set_sys_error(handle->bind_error);
|
||||
uv__set_sys_error(loop, handle->bind_error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -588,7 +588,7 @@ int uv_tcp_getsockname(uv_tcp_t* handle, struct sockaddr* name,
|
||||
}
|
||||
|
||||
if (handle->flags & UV_HANDLE_BIND_ERROR) {
|
||||
uv__set_sys_error(handle->bind_error);
|
||||
uv__set_sys_error(loop, handle->bind_error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -613,7 +613,7 @@ int uv_tcp_getpeername(uv_tcp_t* handle, struct sockaddr* name,
|
||||
}
|
||||
|
||||
if (handle->flags & UV_HANDLE_BIND_ERROR) {
|
||||
uv__set_sys_error(handle->bind_error);
|
||||
uv__set_sys_error(loop, handle->bind_error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -691,7 +691,7 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
/* An error occurred doing the read. */
|
||||
if ((handle->flags & UV_HANDLE_READING)) {
|
||||
handle->flags &= ~UV_HANDLE_READING;
|
||||
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
|
||||
uv__set_sys_error(loop, GET_REQ_SOCK_ERROR(req));
|
||||
buf = (handle->flags & UV_HANDLE_ZERO_READ) ?
|
||||
uv_buf_init(NULL, 0) : handle->read_buffer;
|
||||
handle->read_cb((uv_stream_t*)handle, -1, buf);
|
||||
@ -712,8 +712,7 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
/* Connection closed */
|
||||
handle->flags &= ~UV_HANDLE_READING;
|
||||
handle->flags |= UV_HANDLE_EOF;
|
||||
loop->last_error.code = UV_EOF;
|
||||
loop->last_error.sys_errno_ = ERROR_SUCCESS;
|
||||
uv__set_error(loop, UV_EOF, ERROR_SUCCESS);
|
||||
buf.base = 0;
|
||||
buf.len = 0;
|
||||
handle->read_cb((uv_stream_t*)handle, -1, handle->read_buffer);
|
||||
@ -744,8 +743,7 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
/* Connection closed */
|
||||
handle->flags &= ~UV_HANDLE_READING;
|
||||
handle->flags |= UV_HANDLE_EOF;
|
||||
loop->last_error.code = UV_EOF;
|
||||
loop->last_error.sys_errno_ = ERROR_SUCCESS;
|
||||
uv__set_error(loop, UV_EOF, ERROR_SUCCESS);
|
||||
handle->read_cb((uv_stream_t*)handle, -1, buf);
|
||||
break;
|
||||
}
|
||||
@ -784,8 +782,8 @@ void uv_process_tcp_write_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
handle->write_queue_size -= req->queued_bytes;
|
||||
|
||||
if (req->cb) {
|
||||
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
|
||||
((uv_write_cb)req->cb)(req, loop->last_error.code == UV_OK ? 0 : -1);
|
||||
uv__set_sys_error(loop, GET_REQ_SOCK_ERROR(req));
|
||||
((uv_write_cb)req->cb)(req, loop->last_err.code == UV_OK ? 0 : -1);
|
||||
}
|
||||
|
||||
handle->write_reqs_pending--;
|
||||
@ -812,7 +810,7 @@ void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
if (handle->flags & UV_HANDLE_LISTENING) {
|
||||
handle->flags &= ~UV_HANDLE_LISTENING;
|
||||
if (handle->connection_cb) {
|
||||
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
|
||||
uv__set_sys_error(loop, GET_REQ_SOCK_ERROR(req));
|
||||
handle->connection_cb((uv_stream_t*)handle, -1);
|
||||
}
|
||||
}
|
||||
@ -863,7 +861,7 @@ void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle,
|
||||
((uv_connect_cb)req->cb)(req, -1);
|
||||
}
|
||||
} else {
|
||||
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
|
||||
uv__set_sys_error(loop, GET_REQ_SOCK_ERROR(req));
|
||||
((uv_connect_cb)req->cb)(req, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -452,7 +452,7 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
|
||||
/* An error occurred while waiting for the event. */
|
||||
if ((handle->flags & UV_HANDLE_READING)) {
|
||||
handle->flags &= ~UV_HANDLE_READING;
|
||||
loop->last_error = GET_REQ_UV_ERROR(req);
|
||||
uv__set_sys_error(loop, GET_REQ_ERROR(req));
|
||||
handle->read_cb((uv_stream_t*)handle, -1, uv_null_buf_);
|
||||
}
|
||||
goto out;
|
||||
@ -689,7 +689,7 @@ void uv_process_tty_read_line_req(uv_loop_t* loop, uv_tty_t* handle,
|
||||
!(handle->flags & UV_HANDLE_TTY_RAW)) {
|
||||
/* Real error */
|
||||
handle->flags &= ~UV_HANDLE_READING;
|
||||
loop->last_error = GET_REQ_UV_ERROR(req);
|
||||
uv__set_sys_error(loop, GET_REQ_ERROR(req));
|
||||
handle->read_cb((uv_stream_t*) handle, -1, buf);
|
||||
} else {
|
||||
/* The read was cancelled, or whatever we don't care */
|
||||
@ -1483,7 +1483,7 @@ int uv_tty_write(uv_loop_t* loop, uv_write_t* req, uv_tty_t* handle,
|
||||
|
||||
if ((handle->flags & UV_HANDLE_SHUTTING) ||
|
||||
(handle->flags & UV_HANDLE_CLOSING)) {
|
||||
uv_set_sys_error(loop, WSAESHUTDOWN);
|
||||
uv__set_sys_error(loop, WSAESHUTDOWN);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1515,8 +1515,8 @@ void uv_process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle,
|
||||
handle->write_queue_size -= req->queued_bytes;
|
||||
|
||||
if (req->cb) {
|
||||
loop->last_error = GET_REQ_UV_ERROR(req);
|
||||
((uv_write_cb)req->cb)(req, loop->last_error.code == UV_OK ? 0 : -1);
|
||||
uv__set_sys_error(loop, GET_REQ_ERROR(req));
|
||||
((uv_write_cb)req->cb)(req, loop->last_err.code == UV_OK ? 0 : -1);
|
||||
}
|
||||
|
||||
handle->write_reqs_pending--;
|
||||
|
||||
@ -228,7 +228,7 @@ int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr,
|
||||
sizeof(struct sockaddr_in6),
|
||||
flags);
|
||||
} else {
|
||||
uv_new_sys_error(WSAEAFNOSUPPORT);
|
||||
uv__set_sys_error(loop, WSAEAFNOSUPPORT);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -453,7 +453,7 @@ void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle,
|
||||
GET_REQ_STATUS(req) != STATUS_RECEIVE_EXPEDITED) {
|
||||
/* An error occurred doing the read. */
|
||||
if ((handle->flags & UV_HANDLE_READING)) {
|
||||
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
|
||||
uv__set_sys_error(loop, GET_REQ_SOCK_ERROR(req));
|
||||
uv_udp_recv_stop(handle);
|
||||
#if 0
|
||||
buf = (handle->flags & UV_HANDLE_ZERO_READ) ?
|
||||
@ -540,7 +540,7 @@ void uv_process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle,
|
||||
if (REQ_SUCCESS(req)) {
|
||||
req->cb(req, 0);
|
||||
} else {
|
||||
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
|
||||
uv__set_sys_error(loop, GET_REQ_SOCK_ERROR(req));
|
||||
req->cb(req, -1);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user