* select.cc (peek_pipe): Semi-reinstate pipe NT-special write detection.

This commit is contained in:
Christopher Faylor 2008-05-30 17:56:37 +00:00
parent 4f3af63913
commit 11a36faaa6
2 changed files with 17 additions and 14 deletions

View File

@ -1,3 +1,8 @@
2008-05-30 Christopher Faylor <me+cygwin@cgf.cx>
* select.cc (peek_pipe): Semi-reinstate pipe NT-special write
detection.
2008-05-29 Christopher Faylor <me+cygwin@cgf.cx> 2008-05-29 Christopher Faylor <me+cygwin@cgf.cx>
* devices.in: Change mapping for /dev/ttyS* and /dev/com*. * devices.in: Change mapping for /dev/ttyS* and /dev/com*.

View File

@ -16,6 +16,7 @@ details. */
#include "winsup.h" #include "winsup.h"
#include <stdlib.h> #include <stdlib.h>
#include "ntdll.h"
#include <wingdi.h> #include <wingdi.h>
#include <winuser.h> #include <winuser.h>
@ -294,7 +295,7 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
select_printf ("woke up. wait_ret %d. verifying", wait_ret); select_printf ("woke up. wait_ret %d. verifying", wait_ret);
s = &start; s = &start;
bool gotone = false; bool gotone = false;
/* Some types of object (e.g., consoles) wake up on "inappropriate" events /* Some types of objects (e.g., consoles) wake up on "inappropriate" events
like mouse movements. The verify function will detect these situations. like mouse movements. The verify function will detect these situations.
If it returns false, then this wakeup was a false alarm and we should go If it returns false, then this wakeup was a false alarm and we should go
back to waiting. */ back to waiting. */
@ -505,10 +506,6 @@ out:
fh->get_name ()); fh->get_name ());
else else
{ {
#if 0
/* FIXME: This code is not quite correct. There's no better solution
so far but to always treat the write side of the pipe as writable. */
IO_STATUS_BLOCK iosb = {0}; IO_STATUS_BLOCK iosb = {0};
FILE_PIPE_LOCAL_INFORMATION fpli = {0}; FILE_PIPE_LOCAL_INFORMATION fpli = {0};
@ -519,19 +516,18 @@ out:
FilePipeLocalInformation)) FilePipeLocalInformation))
{ {
/* If NtQueryInformationFile fails, optimistically assume the /* If NtQueryInformationFile fails, optimistically assume the
pipe is writable. This could happen on Win9x, because pipe is writable. This could happen if we somehow
NtQueryInformationFile is not available, or if we somehow
inherit a pipe that doesn't permit FILE_READ_ATTRIBUTES inherit a pipe that doesn't permit FILE_READ_ATTRIBUTES
access on the write end. */ access on the write end. */
select_printf ("%s, NtQueryInformationFile failed", select_printf ("%s, NtQueryInformationFile failed",
fh->get_name ()); fh->get_name ());
gotone += s->write_ready = true; gotone += s->write_ready = true;
} }
/* Ensure that enough space is available for atomic writes, /* If there is anything available in the pipe buffer then signal
as required by POSIX. Subsequent writes with size > PIPE_BUF that. This means that a pipe could still block since you could
can still block, but most (all?) UNIX variants seem to work be trying to write more to the pipe than is available in the
this way (e.g., BSD, Linux, Solaris). */ buffer but that is the hazard of select(). */
else if (fpli.WriteQuotaAvailable >= PIPE_BUF) else if (fpli.WriteQuotaAvailable)
{ {
select_printf ("%s, ready for write: size %lu, avail %lu", select_printf ("%s, ready for write: size %lu, avail %lu",
fh->get_name (), fh->get_name (),
@ -539,6 +535,10 @@ out:
fpli.WriteQuotaAvailable); fpli.WriteQuotaAvailable);
gotone += s->write_ready = true; gotone += s->write_ready = true;
} }
#if 0
/* FIXME: This code is not quite correct. There's no better solution
so far but to make simple assumptions based on WriteQuotaAvailable. */
/* If we somehow inherit a tiny pipe (size < PIPE_BUF), then consider /* If we somehow inherit a tiny pipe (size < PIPE_BUF), then consider
the pipe writable only if it is completely empty, to minimize the the pipe writable only if it is completely empty, to minimize the
probability that a subsequent write will block. */ probability that a subsequent write will block. */
@ -551,8 +551,6 @@ out:
fpli.WriteQuotaAvailable); fpli.WriteQuotaAvailable);
gotone += s->write_ready = true; gotone += s->write_ready = true;
} }
#else
gotone += s->write_ready = true;
#endif #endif
} }
} }