Cygwin: FIFO: reorganize some fifo_client_handler methods

Rename the existing set_state() to query_and_set_state() to reflect
what it really does.  (It queries the O/S for the pipe state.)  Add a
new set_state() method, which is a standard setter, and a
corresponding getter get_state().
This commit is contained in:
Ken Brown
2020-08-03 09:32:30 -04:00
parent 6ed067a0ae
commit 289af73a89
3 changed files with 50 additions and 37 deletions

View File

@@ -875,18 +875,22 @@ peek_fifo (select_record *s, bool from_select)
fh->fifo_client_lock ();
int nconnected = 0;
for (int i = 0; i < fh->get_nhandlers (); i++)
if (fh->get_fc_handler (i).set_state () >= fc_closing)
{
nconnected++;
if (fh->get_fc_handler (i).state == fc_input_avail)
{
select_printf ("read: %s, ready for read", fh->get_name ());
fh->fifo_client_unlock ();
fh->reading_unlock ();
gotone += s->read_ready = true;
goto out;
}
}
{
fifo_client_handler &fc = fh->get_fc_handler (i);
fc.query_and_set_state ();
if (fc.get_state () >= fc_closing)
{
nconnected++;
if (fc.get_state () == fc_input_avail)
{
select_printf ("read: %s, ready for read", fh->get_name ());
fh->fifo_client_unlock ();
fh->reading_unlock ();
gotone += s->read_ready = true;
goto out;
}
}
}
fh->fifo_client_unlock ();
if (!nconnected && fh->hit_eof ())
{