public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: pipes: don't call NtQueryInformationFile on read side of pipes
Date: Wed, 15 Sep 2021 13:42:27 +0000 (GMT) [thread overview]
Message-ID: <20210915134227.EAEFE3858403@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=34b14470406cb9551f98707bf63175811a506523
commit 34b14470406cb9551f98707bf63175811a506523
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Wed Sep 15 14:17:59 2021 +0200
Cygwin: pipes: don't call NtQueryInformationFile on read side of pipes
NtQueryInformationFile hangs if it's called on the read side handle of
a pipe while another thread or process is performing a blocking read.
Avoid select potentially hanging by calling NtQueryInformationFile
only on the write side of the pipe and using PeekNamedPipe otherwise.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/select.cc | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index a09d8a34d..566cf66d6 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -587,6 +587,14 @@ no_verify (select_record *, fd_set *, fd_set *, fd_set *)
static int
pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing)
{
+ if (fh->get_device () == FH_PIPER)
+ {
+ DWORD nbytes_in_pipe;
+ if (!writing && PeekNamedPipe (h, NULL, 0, NULL, &nbytes_in_pipe, NULL))
+ return nbytes_in_pipe > 0;
+ return -1;
+ }
+
IO_STATUS_BLOCK iosb = {{0}, 0};
FILE_PIPE_LOCAL_INFORMATION fpli = {0};
NTSTATUS status;
reply other threads:[~2021-09-15 13:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210915134227.EAEFE3858403@sourceware.org \
--to=corinna@sourceware.org \
--cc=cygwin-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).