From b6bf6d2d1f4c4ec263ee9064060e983ac3ee555f Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Wed, 10 Jun 2015 11:36:41 -0700 Subject: [PATCH] win,stream: add slot to remember CRT fd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Certain types of streams may be opened from a CRT file descriptor (as opposed to a Windows HANDLE). In order to close the file descriptor later, libuv must store the file descriptor used to open the stream. PR-URL: https://github.com/libuv/libuv/pull/396 Reviewed-By: Saúl Ibarra Corretgé --- include/uv.h | 5 ++++- src/uv-common.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/uv.h b/include/uv.h index 564af5fa..82afbee2 100644 --- a/include/uv.h +++ b/include/uv.h @@ -406,7 +406,10 @@ struct uv_shutdown_s { /* private */ \ uv_close_cb close_cb; \ void* handle_queue[2]; \ - void* reserved[4]; \ + union { \ + int fd; \ + void* reserved[4]; \ + } u; \ UV_HANDLE_PRIVATE_FIELDS \ /* The abstract base class of all handles. */ diff --git a/src/uv-common.h b/src/uv-common.h index 8258d7a1..b348ec76 100644 --- a/src/uv-common.h +++ b/src/uv-common.h @@ -196,7 +196,7 @@ void uv__fs_scandir_cleanup(uv_fs_t* req); (((h)->flags & UV__HANDLE_REF) != 0) #if defined(_WIN32) -# define uv__handle_platform_init(h) +# define uv__handle_platform_init(h) ((h)->u.fd = -1) #else # define uv__handle_platform_init(h) ((h)->next_closing = NULL) #endif