Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
uv: upgrade 8c78cb4
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Mar 9, 2012
1 parent 0c68604 commit 9d72a74
Show file tree
Hide file tree
Showing 31 changed files with 808 additions and 181 deletions.
2 changes: 1 addition & 1 deletion deps/uv/config-mingw.mk
Expand Up @@ -34,7 +34,7 @@ WIN_OBJS=$(WIN_SRCS:.c=.o)

RUNNER_CFLAGS=$(CFLAGS) -D_GNU_SOURCE # Need _GNU_SOURCE for strdup?
RUNNER_LINKFLAGS=$(LINKFLAGS)
RUNNER_LIBS=-lws2_32
RUNNER_LIBS=-lws2_32 -lpsapi -liphlpapi
RUNNER_SRC=test/runner-win.c

uv.a: $(WIN_OBJS) src/uv-common.o $(CARES_OBJS)
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/include/uv.h
Expand Up @@ -1388,7 +1388,7 @@ UV_EXTERN extern uint64_t uv_hrtime(void);


/*
* Opens a shared library. The filename is in utf-8. On success, -1 is
* Opens a shared library. The filename is in utf-8. On success, -1 is returned
* and the variable pointed by library receives a handle to the library.
*/
UV_EXTERN uv_err_t uv_dlopen(const char* filename, uv_lib_t* library);
Expand Down
1 change: 1 addition & 0 deletions deps/uv/src/unix/cygwin.c
Expand Up @@ -19,6 +19,7 @@
*/

#include "uv.h"
#include "../uv-common.h"

#include <assert.h>
#include <stdint.h>
Expand Down
38 changes: 32 additions & 6 deletions deps/uv/src/unix/stream.c
Expand Up @@ -22,14 +22,17 @@
#include "uv.h"
#include "internal.h"

#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/uio.h>
#include <assert.h>
#include <errno.h>

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <sys/un.h>
#include <unistd.h>


static void uv__stream_connect(uv_stream_t*);
Expand Down Expand Up @@ -513,6 +516,28 @@ static void uv__write_callbacks(uv_stream_t* stream) {
}


static uv_handle_type uv__handle_type(int fd) {
struct sockaddr_storage ss;
socklen_t len;

memset(&ss, 0, sizeof(ss));
len = sizeof(ss);

if (getsockname(fd, (struct sockaddr*)&ss, &len))
return UV_UNKNOWN_HANDLE;

switch (ss.ss_family) {
case AF_UNIX:
return UV_NAMED_PIPE;
case AF_INET:
case AF_INET6:
return UV_TCP;
}

return UV_UNKNOWN_HANDLE;
}


static void uv__read(uv_stream_t* stream) {
uv_buf_t buf;
ssize_t nread;
Expand Down Expand Up @@ -633,7 +658,8 @@ static void uv__read(uv_stream_t* stream) {


if (stream->accepted_fd >= 0) {
stream->read2_cb((uv_pipe_t*)stream, nread, buf, UV_TCP);
stream->read2_cb((uv_pipe_t*)stream, nread, buf,
uv__handle_type(stream->accepted_fd));
} else {
stream->read2_cb((uv_pipe_t*)stream, nread, buf, UV_UNKNOWN_HANDLE);
}
Expand Down
1 change: 1 addition & 0 deletions deps/uv/src/win/core.c
Expand Up @@ -59,6 +59,7 @@ static void uv_init(void) {


static void uv_loop_init(uv_loop_t* loop) {
loop->uv_ares_handles_ = NULL;
/* Create an I/O completion port */
loop->iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
if (loop->iocp == NULL) {
Expand Down
2 changes: 2 additions & 0 deletions deps/uv/src/win/error.c
Expand Up @@ -91,6 +91,8 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case WSAEFAULT: return UV_EFAULT;
case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH;
case WSAEHOSTUNREACH: return UV_EHOSTUNREACH;
case ERROR_OPERATION_ABORTED: return UV_EINTR;
case WSAEINTR: return UV_EINTR;
case ERROR_INVALID_DATA: return UV_EINVAL;
case WSAEINVAL: return UV_EINVAL;
case ERROR_CANT_RESOLVE_FILENAME: return UV_ELOOP;
Expand Down
3 changes: 2 additions & 1 deletion deps/uv/src/win/fs.c
Expand Up @@ -547,7 +547,8 @@ static void fs__stat(uv_fs_t* req, const wchar_t* path) {
req->stat.st_size = ((int64_t) info.nFileSizeHigh << 32) +
(int64_t) info.nFileSizeLow;

req->stat.st_nlink = info.nNumberOfLinks;
req->stat.st_nlink = (info.nNumberOfLinks <= SHRT_MAX) ?
(short) info.nNumberOfLinks : SHRT_MAX;

req->ptr = &req->stat;
req->result = 0;
Expand Down
15 changes: 11 additions & 4 deletions deps/uv/src/win/handle.c
Expand Up @@ -27,9 +27,15 @@


uv_handle_type uv_guess_handle(uv_file file) {
HANDLE handle = (HANDLE) _get_osfhandle(file);
HANDLE handle;
DWORD mode;

if (file < 0) {
return UV_UNKNOWN_HANDLE;
}

handle = (HANDLE) _get_osfhandle(file);

switch (GetFileType(handle)) {
case FILE_TYPE_CHAR:
if (GetConsoleMode(handle, &mode)) {
Expand Down Expand Up @@ -85,9 +91,10 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) {
tcp = (uv_tcp_t*)handle;
/* If we don't shutdown before calling closesocket, windows will */
/* silently discard the kernel send buffer and reset the connection. */
if (!(tcp->flags & UV_HANDLE_SHUT)) {
if ((tcp->flags & UV_HANDLE_CONNECTION) &&
!(tcp->flags & UV_HANDLE_SHUT)) {
shutdown(tcp->socket, SD_SEND);
tcp->flags |= UV_HANDLE_SHUT;
tcp->flags |= UV_HANDLE_SHUTTING | UV_HANDLE_SHUT;
}
tcp->flags &= ~(UV_HANDLE_READING | UV_HANDLE_LISTENING);
closesocket(tcp->socket);
Expand Down Expand Up @@ -173,7 +180,7 @@ void uv_want_endgame(uv_loop_t* loop, uv_handle_t* handle) {
void uv_process_endgames(uv_loop_t* loop) {
uv_handle_t* handle;

while (loop->endgame_handles) {
while (loop->endgame_handles && loop->refs > 0) {
handle = loop->endgame_handles;
loop->endgame_handles = handle->endgame_next;

Expand Down

0 comments on commit 9d72a74

Please sign in to comment.