Cygwin: FIFO: introduce a new type, fifo_reader_id_t

This uniquely identifies an fhandler_fifo open for reading in any
process.

Add a new data member 'me' of this type, which is set in open, dup,
fork, and exec.
This commit is contained in:
Ken Brown
2020-03-25 19:22:10 -04:00
parent 365818a4a5
commit 16e7c10578
2 changed files with 31 additions and 1 deletions

View File

@@ -1300,6 +1300,26 @@ struct fifo_client_handler
int pipe_state ();
};
class fhandler_fifo;
struct fifo_reader_id_t
{
DWORD winpid;
fhandler_fifo *fh;
operator bool () const { return winpid != 0 || fh != NULL; }
friend operator == (const fifo_reader_id_t &l, const fifo_reader_id_t &r)
{
return l.winpid == r.winpid && l.fh == r.fh;
}
friend operator != (const fifo_reader_id_t &l, const fifo_reader_id_t &r)
{
return l.winpid != r.winpid || l.fh != r.fh;
}
};
/* Info needed by all readers of a FIFO, stored in named shared memory. */
class fifo_shmem_t
{
@@ -1329,6 +1349,7 @@ class fhandler_fifo: public fhandler_base
af_unix_spinlock_t _fifo_client_lock;
bool reader, writer, duplexer;
size_t max_atomic_write;
fifo_reader_id_t me;
HANDLE shmem_handle;
fifo_shmem_t *shmem;
@@ -1362,6 +1383,8 @@ public:
void fifo_client_lock () { _fifo_client_lock.lock (); }
void fifo_client_unlock () { _fifo_client_lock.unlock (); }
fifo_reader_id_t get_me () const { return me; }
int open (int, mode_t);
off_t lseek (off_t offset, int whence);
int close ();