From 968562d2d1777afc9cf777e713fdd2820b6511ed Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Tue, 3 May 2022 13:25:02 +0200 Subject: [PATCH] [win32] Moved code. --- src/osdep/win32/overrides.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/osdep/win32/overrides.c b/src/osdep/win32/overrides.c index 3f7ee771..70c0d9aa 100644 --- a/src/osdep/win32/overrides.c +++ b/src/osdep/win32/overrides.c @@ -551,12 +551,18 @@ select_read(int fd, struct fd_set *rd) int rc = 0; HANDLE hnd = (HANDLE) fd; - if (hnd == GetStdHandle(STD_INPUT_HANDLE)) { + if (GetFileType(hnd) == FILE_TYPE_PIPE) { + DWORD read = 0; + if (PeekNamedPipe(hnd, NULL, 0, NULL, &read, NULL) + && read > 0) { + FD_SET (fd, rd); + rc++; + } + } else if (hnd == GetStdHandle(STD_INPUT_HANDLE)) { if (console_peek(hnd)) { FD_SET(fd, rd); rc++; } - } else { hnd = (HANDLE) _get_osfhandle(fd); if (WaitForSingleObject(hnd, 0) == WAIT_OBJECT_0) { @@ -576,21 +582,10 @@ select_one_loop(int num_fds, struct fd_set *rd, struct fd_set *wr, int rc, fd; for (rc = fd = 0; fd < num_fds; fd++) { - HANDLE hnd = (HANDLE)fd; - - if (GetFileType(hnd) == FILE_TYPE_PIPE) { - DWORD read = 0; - if (PeekNamedPipe(hnd, NULL, 0, NULL, &read, NULL) - && read > 0) { - FD_SET (fd, rd); - rc++; - } - - } else if (fd < SOCK_SHIFT) { + if (fd < SOCK_SHIFT) { rc += select_read(fd, rd); if (wr && FD_ISSET(fd,wr)) rc++; /* assume always writable */ - } else { /* A Winsock socket */ fd_set sock_rd, sock_wr, sock_ex;