Cygwin: FIFO: add a timeout to take_ownership
fhandler_fifo::take_ownership() is called from select.cc::peek_fifo and fhandler_fifo::raw_read and could potentially block indefinitely if something goes wrong. This is always undesirable in peek_fifo, and it is undesirable in a nonblocking read. Fix this by adding a timeout parameter to take_ownership. Arbitrarily use a 1 ms timeout in peek_fifo and a 10 ms timeout in raw_read. These numbers may have to be tweaked based on experience. Replace the call to cygwait in take_ownership by a call to WFSO. There's no need to allow interruption now that we have a timeout.
This commit is contained in:
@@ -867,16 +867,11 @@ peek_fifo (select_record *s, bool from_select)
|
||||
}
|
||||
|
||||
fh->reading_lock ();
|
||||
if (fh->take_ownership () != WAIT_OBJECT_0)
|
||||
if (fh->take_ownership (1) < 0)
|
||||
{
|
||||
select_printf ("%s, unable to take ownership", fh->get_name ());
|
||||
fh->reading_unlock ();
|
||||
gotone += s->read_ready = true;
|
||||
if (s->except_selected)
|
||||
gotone += s->except_ready = true;
|
||||
goto out;
|
||||
}
|
||||
|
||||
fh->fifo_client_lock ();
|
||||
int nconnected = 0;
|
||||
for (int i = 0; i < fh->get_nhandlers (); i++)
|
||||
|
Reference in New Issue
Block a user