Permalink
Browse files

uv: upgrade 8c78cb4

  • Loading branch information...
1 parent 0c68604 commit 9d72a742e3c35c13e24e69184a4befe5a7e84fef @bnoordhuis bnoordhuis committed Mar 9, 2012
View
@@ -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)
View
@@ -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);
@@ -19,6 +19,7 @@
*/
#include "uv.h"
+#include "../uv-common.h"
#include <assert.h>
#include <stdint.h>
View
@@ -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*);
@@ -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;
@@ -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);
}
View
@@ -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) {
View
@@ -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;
View
@@ -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;
View
@@ -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)) {
@@ -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);
@@ -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;
Oops, something went wrong.

0 comments on commit 9d72a74

Please sign in to comment.