Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2011-11-29 19:34:49 +0400
committerChristopher Faylor <me@cgf.cx>2011-11-29 19:34:49 +0400
commit480b13a37aa1ca2e8ef6135a6d8dd9462c3df30e (patch)
treea612763e4e2bbc4d5298581ea617b73e8af693cd /winsup/cygwin/select.cc
parentd1fc77322f7e413e2d717d006ffe0a55f913e2b2 (diff)
* sigproc.cc (remove_proc): Don't terminate the currently executing thread.
Diffstat (limited to 'winsup/cygwin/select.cc')
-rw-r--r--winsup/cygwin/select.cc79
1 files changed, 41 insertions, 38 deletions
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index c3d3c950d..d92642b21 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -484,48 +484,51 @@ pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing)
FILE_PIPE_LOCAL_INFORMATION fpli = {0};
bool res = false;
- if (NtQueryInformationFile (h,
- &iosb,
- &fpli,
- sizeof (fpli),
- FilePipeLocalInformation))
+ if (!fh->has_ongoing_io ())
{
- /* If NtQueryInformationFile fails, optimistically assume the
- pipe is writable. This could happen if we somehow
- inherit a pipe that doesn't permit FILE_READ_ATTRIBUTES
- access on the write end. */
- select_printf ("fd %d, %s, NtQueryInformationFile failed",
- fd, fh->get_name ());
- res = writing ? true : -1;
- }
- else if (!writing)
- {
- res = !!fpli.ReadDataAvailable;
- paranoid_printf ("fd %d, %s, read avail %u", fd, fh->get_name (), fpli.ReadDataAvailable);
- }
- else
- {
- /* If there is anything available in the pipe buffer then signal
- that. This means that a pipe could still block since you could
- be trying to write more to the pipe than is available in the
- buffer but that is the hazard of select(). */
- if ((fpli.WriteQuotaAvailable = (fpli.OutboundQuota - fpli.ReadDataAvailable)))
+ if (NtQueryInformationFile (h,
+ &iosb,
+ &fpli,
+ sizeof (fpli),
+ FilePipeLocalInformation))
+ {
+ /* If NtQueryInformationFile fails, optimistically assume the
+ pipe is writable. This could happen if we somehow
+ inherit a pipe that doesn't permit FILE_READ_ATTRIBUTES
+ access on the write end. */
+ select_printf ("fd %d, %s, NtQueryInformationFile failed",
+ fd, fh->get_name ());
+ res = writing ? true : -1;
+ }
+ else if (!writing)
{
- paranoid_printf ("fd %d, %s, write: size %lu, avail %lu", fd,
- fh->get_name (), fpli.OutboundQuota,
- fpli.WriteQuotaAvailable);
- res = true;
+ res = !!fpli.ReadDataAvailable;
+ paranoid_printf ("fd %d, %s, read avail %u", fd, fh->get_name (), fpli.ReadDataAvailable);
}
- /* If we somehow inherit a tiny pipe (size < PIPE_BUF), then consider
- the pipe writable only if it is completely empty, to minimize the
- probability that a subsequent write will block. */
- else if (fpli.OutboundQuota < PIPE_BUF &&
- fpli.WriteQuotaAvailable == fpli.OutboundQuota)
+ else
{
- select_printf ("fd, %s, write tiny pipe: size %lu, avail %lu",
- fd, fh->get_name (), fpli.OutboundQuota,
- fpli.WriteQuotaAvailable);
- res = true;
+ /* If there is anything available in the pipe buffer then signal
+ that. This means that a pipe could still block since you could
+ be trying to write more to the pipe than is available in the
+ buffer but that is the hazard of select(). */
+ if ((fpli.WriteQuotaAvailable = (fpli.OutboundQuota - fpli.ReadDataAvailable)))
+ {
+ paranoid_printf ("fd %d, %s, write: size %lu, avail %lu", fd,
+ fh->get_name (), fpli.OutboundQuota,
+ fpli.WriteQuotaAvailable);
+ res = true;
+ }
+ /* If we somehow inherit a tiny pipe (size < PIPE_BUF), then consider
+ the pipe writable only if it is completely empty, to minimize the
+ probability that a subsequent write will block. */
+ else if (fpli.OutboundQuota < PIPE_BUF &&
+ fpli.WriteQuotaAvailable == fpli.OutboundQuota)
+ {
+ select_printf ("fd, %s, write tiny pipe: size %lu, avail %lu",
+ fd, fh->get_name (), fpli.OutboundQuota,
+ fpli.WriteQuotaAvailable);
+ res = true;
+ }
}
}
return res ?: -!!(fpli.NamedPipeState & FILE_PIPE_CLOSING_STATE);