ext/noderb_extension/libuv/src/win/handle.c in noderb-0.0.10 vs ext/noderb_extension/libuv/src/win/handle.c in noderb-0.0.11

- old
+ new

@@ -18,15 +18,40 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #include <assert.h> +#include <io.h> #include "uv.h" #include "internal.h" +uv_handle_type uv_guess_handle(uv_file file) { + HANDLE handle = (HANDLE) _get_osfhandle(file); + DWORD mode; + + switch (GetFileType(handle)) { + case FILE_TYPE_CHAR: + if (GetConsoleMode(handle, &mode)) { + return UV_TTY; + } else { + return UV_UNKNOWN_HANDLE; + } + + case FILE_TYPE_PIPE: + return UV_NAMED_PIPE; + + case FILE_TYPE_DISK: + return UV_FILE; + + default: + return UV_UNKNOWN_HANDLE; + } +} + + int uv_is_active(uv_handle_t* handle) { switch (handle->type) { case UV_TIMER: case UV_IDLE: case UV_PREPARE: @@ -78,10 +103,14 @@ if (pipe->reqs_pending == 0) { uv_want_endgame(loop, handle); } return; + case UV_TTY: + uv_tty_close((uv_tty_t*) handle); + return; + case UV_UDP: udp = (uv_udp_t*) handle; uv_udp_recv_stop(udp); closesocket(udp->socket); if (udp->reqs_pending == 0) { @@ -118,10 +147,14 @@ case UV_PROCESS: process = (uv_process_t*)handle; uv_process_close(loop, process); return; + case UV_FS_EVENT: + uv_fs_event_close(loop, (uv_fs_event_t*)handle); + return; + default: /* Not supported */ abort(); } } @@ -153,10 +186,14 @@ case UV_NAMED_PIPE: uv_pipe_endgame(loop, (uv_pipe_t*) handle); break; + case UV_TTY: + uv_tty_endgame(loop, (uv_tty_t*) handle); + break; + case UV_UDP: uv_udp_endgame(loop, (uv_udp_t*) handle); break; case UV_TIMER: @@ -173,9 +210,13 @@ uv_async_endgame(loop, (uv_async_t*) handle); break; case UV_PROCESS: uv_process_endgame(loop, (uv_process_t*) handle); + break; + + case UV_FS_EVENT: + uv_fs_event_endgame(loop, (uv_fs_event_t*) handle); break; default: assert(0); break;