Cygwin: FIFO: allow any reader to take ownership
Add a take_ownership method, used by raw_read and select.cc:peek_fifo. It wakes up all fifo_reader_threads and allows the caller to become owner. The work is done by the fifo_reader_threads. For synchronization we introduce several new fhandler_fifo data members and methods: - update_needed_evt signals the current owner to stop listening for writer connections and update its fc_handler list. - shared_fc_handler() gets and sets the status of the fc_handler update process. - get_pending_owner() and set_pending_owner() get and set the reader that is requesting ownership. Finally, a new 'reading_lock' prevents two readers from trying to take ownership simultaneously.
This commit is contained in:
@@ -866,6 +866,8 @@ peek_fifo (select_record *s, bool from_select)
|
||||
goto out;
|
||||
}
|
||||
|
||||
fh->reading_lock ();
|
||||
fh->take_ownership ();
|
||||
fh->fifo_client_lock ();
|
||||
int nconnected = 0;
|
||||
for (int i = 0; i < fh->get_nhandlers (); i++)
|
||||
@@ -888,6 +890,7 @@ peek_fifo (select_record *s, bool from_select)
|
||||
fh->get_fc_handler (i).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;
|
||||
default:
|
||||
@@ -905,6 +908,7 @@ peek_fifo (select_record *s, bool from_select)
|
||||
if (s->except_selected)
|
||||
gotone += s->except_ready = true;
|
||||
}
|
||||
fh->reading_unlock ();
|
||||
}
|
||||
out:
|
||||
if (s->write_selected)
|
||||
|
Reference in New Issue
Block a user