} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
typedef DWORD (WINAPI *PNtQueryInformationFile)
} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
typedef DWORD (WINAPI *PNtQueryInformationFile)
- (HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS);
+ (HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS);
static int
win32_poll_handle (HANDLE h, int fd, struct bitset *rbits, struct bitset *wbits,
static int
win32_poll_handle (HANDLE h, int fd, struct bitset *rbits, struct bitset *wbits,
- {
- NtQueryInformationFile = (PNtQueryInformationFile)
- GetProcAddress (GetModuleHandle ("ntdll.dll"),
- "NtQueryInformationFile");
- once_only = TRUE;
- }
+ {
+ NtQueryInformationFile = (PNtQueryInformationFile)
+ GetProcAddress (GetModuleHandle ("ntdll.dll"),
+ "NtQueryInformationFile");
+ once_only = TRUE;
+ }
if (PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL) != 0)
if (PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL) != 0)
- {
- /* It was the write-end of the pipe. Check if it is writable.
- If NtQueryInformationFile fails, optimistically assume the pipe is
- writable. This could happen on Win9x, where NtQueryInformationFile
- is not available, or if we inherit a pipe that doesn't permit
- FILE_READ_ATTRIBUTES access on the write end (I think this should
- not happen since WinXP SP2; WINE seems fine too). Otherwise,
- ensure that enough space is available for atomic writes. */
+ {
+ /* It was the write-end of the pipe. Check if it is writable.
+ If NtQueryInformationFile fails, optimistically assume the pipe is
+ writable. This could happen on Win9x, where NtQueryInformationFile
+ is not available, or if we inherit a pipe that doesn't permit
+ FILE_READ_ATTRIBUTES access on the write end (I think this should
+ not happen since WinXP SP2; WINE seems fine too). Otherwise,
+ ensure that enough space is available for atomic writes. */
memset (&iosb, 0, sizeof (iosb));
memset (&fpli, 0, sizeof (fpli));
if (!NtQueryInformationFile
|| NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli),
memset (&iosb, 0, sizeof (iosb));
memset (&fpli, 0, sizeof (fpli));
if (!NtQueryInformationFile
|| NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli),
- FilePipeLocalInformation)
- || fpli.WriteQuotaAvailable >= PIPE_BUF
- || (fpli.OutboundQuota < PIPE_BUF &&
- fpli.WriteQuotaAvailable == fpli.OutboundQuota))
- write = TRUE;
- }
+ FilePipeLocalInformation)
+ || fpli.WriteQuotaAvailable >= PIPE_BUF
+ || (fpli.OutboundQuota < PIPE_BUF &&
+ fpli.WriteQuotaAvailable == fpli.OutboundQuota))
+ write = TRUE;
+ }
ret = WaitForSingleObject (h, 0);
if (ret == WAIT_OBJECT_0)
{
ret = WaitForSingleObject (h, 0);
if (ret == WAIT_OBJECT_0)
{
- if (!IsConsoleHandle (h))
- {
- read = TRUE;
- break;
- }
-
- nbuffer = avail = 0;
- bRet = GetNumberOfConsoleInputEvents (h, &nbuffer);
-
- /* Screen buffers handles are filtered earlier. */
- assert (bRet);
- if (nbuffer == 0)
- {
- except = TRUE;
- break;
- }
-
- irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD));
- bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail);
- if (!bRet || avail == 0)
- {
- except = TRUE;
- break;
- }
-
- for (i = 0; i < avail; i++)
- if (irbuffer[i].EventType == KEY_EVENT)
- read = TRUE;
- }
+ if (!IsConsoleHandle (h))
+ {
+ read = TRUE;
+ break;
+ }
+
+ nbuffer = avail = 0;
+ bRet = GetNumberOfConsoleInputEvents (h, &nbuffer);
+
+ /* Screen buffers handles are filtered earlier. */
+ assert (bRet);
+ if (nbuffer == 0)
+ {
+ except = TRUE;
+ break;
+ }
+
+ irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD));
+ bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail);
+ if (!bRet || avail == 0)
+ {
+ except = TRUE;
+ break;
+ }
+
+ for (i = 0; i < avail; i++)
+ if (irbuffer[i].EventType == KEY_EVENT)
+ read = TRUE;
+ }
- h = (HANDLE) _get_osfhandle (fd);
- if (IsConsoleHandle (h)
- && !GetNumberOfConsoleInputEvents (h, &nbuffer))
- continue;
+ h = (HANDLE) _get_osfhandle (fd);
+ if (IsConsoleHandle (h)
+ && !GetNumberOfConsoleInputEvents (h, &nbuffer))
+ continue;
rbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
rbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
- h = (HANDLE) _get_osfhandle (fd);
- if (IsConsoleHandle (h)
- && GetNumberOfConsoleInputEvents (h, &nbuffer))
- continue;
+ h = (HANDLE) _get_osfhandle (fd);
+ if (IsConsoleHandle (h)
+ && GetNumberOfConsoleInputEvents (h, &nbuffer))
+ continue;
wbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
wbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
/* Classify handles. Create fd sets for sockets, poll the others. */
for (i = 0; i < nfds; i++)
{
/* Classify handles. Create fd sets for sockets, poll the others. */
for (i = 0; i < nfds; i++)
{
int requested = FD_CLOSE;
/* See above; socket handles are mapped onto select, but we
int requested = FD_CLOSE;
/* See above; socket handles are mapped onto select, but we
- FD_SET ((SOCKET) h, rfds);
- FD_SET ((SOCKET) h, &handle_rfds);
- }
+ FD_SET ((SOCKET) h, rfds);
+ FD_SET ((SOCKET) h, &handle_rfds);
+ }
- FD_SET ((SOCKET) h, wfds);
- FD_SET ((SOCKET) h, &handle_wfds);
- }
+ FD_SET ((SOCKET) h, wfds);
+ FD_SET ((SOCKET) h, &handle_wfds);
+ }
- FD_SET ((SOCKET) h, xfds);
- FD_SET ((SOCKET) h, &handle_xfds);
- }
+ FD_SET ((SOCKET) h, xfds);
+ FD_SET ((SOCKET) h, &handle_xfds);
+ }
- && win32_poll_handle (h, i, &rbits, &wbits, &xbits))
- wait_timeout = 0;
+ && win32_poll_handle (h, i, &rbits, &wbits, &xbits))
+ wait_timeout = 0;
no need to call select again. */
rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0);
if (rc == 0)
no need to call select again. */
rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0);
if (rc == 0)
memcpy (&handle_rfds, rfds, sizeof (fd_set));
memcpy (&handle_wfds, wfds, sizeof (fd_set));
memcpy (&handle_xfds, xfds, sizeof (fd_set));
memcpy (&handle_rfds, rfds, sizeof (fd_set));
memcpy (&handle_wfds, wfds, sizeof (fd_set));
memcpy (&handle_xfds, xfds, sizeof (fd_set));
for (;;)
{
ret = MsgWaitForMultipleObjects (nhandles, handle_array, FALSE,
for (;;)
{
ret = MsgWaitForMultipleObjects (nhandles, handle_array, FALSE,
while ((bRet = PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) != 0)
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
while ((bRet = PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) != 0)
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
- {
- /* Perform handle->descriptor mapping. Don't update rc, as these
- results are counted in the return value of Winsock's select. */
+ {
+ /* Perform handle->descriptor mapping. Don't update rc, as these
+ results are counted in the return value of Winsock's select. */
WSAEventSelect ((SOCKET) h, NULL, 0);
if (FD_ISSET (h, &handle_rfds))
FD_SET (i, rfds);
WSAEventSelect ((SOCKET) h, NULL, 0);
if (FD_ISSET (h, &handle_rfds))
FD_SET (i, rfds);
win32_poll_handle (h, i, &rbits, &wbits, &xbits);
if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
{
win32_poll_handle (h, i, &rbits, &wbits, &xbits);
if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
{