* select.cc (peek_pipe): Only grab mutex when we actually got something from

the pipe.
This commit is contained in:
Christopher Faylor
2001-09-24 22:49:12 +00:00
parent 35f879a6d0
commit 3263838430
4 changed files with 19 additions and 9 deletions

View File

@@ -449,17 +449,17 @@ peek_pipe (select_record *s, int ignra, HANDLE guard_mutex = NULL)
if (fh->get_device () == FH_PIPEW)
/* nothing */;
else if (!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL))
{
select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ());
n = -1;
}
else if (guard_mutex && WaitForSingleObject (guard_mutex, 0) != WAIT_OBJECT_0)
{
select_printf ("%s, couldn't get mutex %p, %E", fh->get_name (),
guard_mutex);
n = 0;
}
else if (!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL))
{
select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ());
n = -1;
}
if (n < 0)
{