Cygwin: FIFO: reduce I/O interleaving

Add a bool member 'last_read' to the fifo_client_handler structure,
which is set to true on a successful read.  This is used by raw_read
as follows.

When raw_read is called, it first locates the writer (if any) for
which last_read is true.  raw_read tries to read from that writer and
returns if there is input available.  Otherwise, it proceeds to poll
all the writers, as before.

The effect of this is that if a writer writes some data that is only
partially read, the next attempt to read will continue to read from
the same writer.  This should reduce the interleaving of output from
different writers.
This commit is contained in:
Ken Brown
2020-07-11 14:34:24 -04:00
parent e10425e1e3
commit 1c0cf5f4f9
2 changed files with 50 additions and 8 deletions

View File

@@ -1298,7 +1298,8 @@ struct fifo_client_handler
{
HANDLE h;
fifo_client_connect_state state;
fifo_client_handler () : h (NULL), state (fc_unknown) {}
bool last_read; /* true if our last successful read was from this client. */
fifo_client_handler () : h (NULL), state (fc_unknown), last_read (false) {}
void close () { NtClose (h); }
fifo_client_connect_state set_state ();
};