mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-18 23:12:15 +08:00
Cygwin: pipe: Do not call PeekNamedPipe() if it is not necessary.
- In pipe_data_available() in select.cc, PeekNamedPipe() call is not needed if WriteQuotaAvailable is non-zero because we already know the write pipe has a space. Therefore, with this patch, PeekNamedPipe() is called only when WriteQuotaAvailable is zero. This makes select() on pipe faster a bit.
This commit is contained in:
parent
593a86f9b0
commit
00cbbaa33e
@ -633,17 +633,15 @@ pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing)
|
|||||||
/* Note: Do not use NtQueryInformationFile() for query_hdl because
|
/* Note: Do not use NtQueryInformationFile() for query_hdl because
|
||||||
NtQueryInformationFile() seems to interfere with reading pipes
|
NtQueryInformationFile() seems to interfere with reading pipes
|
||||||
in non-cygwin apps. Instead, use PeekNamedPipe() here. */
|
in non-cygwin apps. Instead, use PeekNamedPipe() here. */
|
||||||
if (fh->get_device () == FH_PIPEW)
|
if (fh->get_device () == FH_PIPEW && fpli.WriteQuotaAvailable == 0)
|
||||||
{
|
{
|
||||||
HANDLE query_hdl = ((fhandler_pipe *) fh)->get_query_handle ();
|
HANDLE query_hdl = ((fhandler_pipe *) fh)->get_query_handle ();
|
||||||
if (query_hdl)
|
if (!query_hdl)
|
||||||
{
|
return 1; /* We cannot know actual write pipe space. */
|
||||||
DWORD nbytes_in_pipe;
|
DWORD nbytes_in_pipe;
|
||||||
PeekNamedPipe (query_hdl, NULL, 0, NULL, &nbytes_in_pipe, NULL);
|
if (!PeekNamedPipe (query_hdl, NULL, 0, NULL, &nbytes_in_pipe, NULL))
|
||||||
fpli.WriteQuotaAvailable = fpli.InboundQuota - nbytes_in_pipe;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return 1;
|
return 1;
|
||||||
|
fpli.WriteQuotaAvailable = fpli.InboundQuota - nbytes_in_pipe;
|
||||||
}
|
}
|
||||||
if (fpli.WriteQuotaAvailable > 0)
|
if (fpli.WriteQuotaAvailable > 0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user