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

Commit

Permalink
fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Zinkovsky committed Sep 28, 2011
1 parent 23796d2 commit e7a53ae
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 54 deletions.
4 changes: 1 addition & 3 deletions include/uv-private/uv-win.h
Expand Up @@ -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 */ \
Expand Down
5 changes: 0 additions & 5 deletions src/unix/error.c
Expand Up @@ -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_);
}
Expand Down
5 changes: 5 additions & 0 deletions src/uv-common.c
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/win/core.c
Expand Up @@ -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_;
}


Expand Down
12 changes: 0 additions & 12 deletions src/win/error.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/win/fs-event.c
Expand Up @@ -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);
}

Expand Down
6 changes: 0 additions & 6 deletions src/win/internal.h
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/win/pipe.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand Down
30 changes: 14 additions & 16 deletions src/win/tcp.c
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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--;
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/win/tty.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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--;
Expand Down
6 changes: 3 additions & 3 deletions src/win/udp.c
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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) ?
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit e7a53ae

Please sign in to comment.