Skip to content

Commit 1ac37de

Browse files
committed
Merge branch 'am/mingw-poll-fix'
MinGW's poll() emulation has been improved. * am/mingw-poll-fix: mingw: workaround for hangs when sending STDIN
2 parents cf372dc + 94f4d01 commit 1ac37de

File tree

1 file changed

+3
-28
lines changed

1 file changed

+3
-28
lines changed

compat/poll/poll.c

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,10 @@ win32_compute_revents (HANDLE h, int *p_sought)
139139
INPUT_RECORD *irbuffer;
140140
DWORD avail, nbuffer;
141141
BOOL bRet;
142-
IO_STATUS_BLOCK iosb;
143-
FILE_PIPE_LOCAL_INFORMATION fpli;
144-
static PNtQueryInformationFile NtQueryInformationFile;
145-
static BOOL once_only;
146142

147143
switch (GetFileType (h))
148144
{
149145
case FILE_TYPE_PIPE:
150-
if (!once_only)
151-
{
152-
NtQueryInformationFile = (PNtQueryInformationFile)(void (*)(void))
153-
GetProcAddress (GetModuleHandleW (L"ntdll.dll"),
154-
"NtQueryInformationFile");
155-
once_only = TRUE;
156-
}
157-
158146
happened = 0;
159147
if (PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL) != 0)
160148
{
@@ -166,22 +154,9 @@ win32_compute_revents (HANDLE h, int *p_sought)
166154

167155
else
168156
{
169-
/* It was the write-end of the pipe. Check if it is writable.
170-
If NtQueryInformationFile fails, optimistically assume the pipe is
171-
writable. This could happen on Win9x, where NtQueryInformationFile
172-
is not available, or if we inherit a pipe that doesn't permit
173-
FILE_READ_ATTRIBUTES access on the write end (I think this should
174-
not happen since WinXP SP2; WINE seems fine too). Otherwise,
175-
ensure that enough space is available for atomic writes. */
176-
memset (&iosb, 0, sizeof (iosb));
177-
memset (&fpli, 0, sizeof (fpli));
178-
179-
if (!NtQueryInformationFile
180-
|| NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli),
181-
FilePipeLocalInformation)
182-
|| fpli.WriteQuotaAvailable >= PIPE_BUF
183-
|| (fpli.OutboundQuota < PIPE_BUF &&
184-
fpli.WriteQuotaAvailable == fpli.OutboundQuota))
157+
/* It was the write-end of the pipe. Unfortunately there is no
158+
reliable way of knowing if it can be written without blocking.
159+
Just say that it's all good. */
185160
happened |= *p_sought & (POLLOUT | POLLWRNORM | POLLWRBAND);
186161
}
187162
return happened;

0 commit comments

Comments
 (0)