Cygwin: FIFO: keep track of the number of readers
Add data and methods to the shared memory that keep track of the number of open readers. Increment this number in open, dup, fork, and exec. Decrement it in close. Reset read_ready if there are no readers left.
This commit is contained in:
@ -1303,6 +1303,11 @@ struct fifo_client_handler
|
||||
/* Info needed by all readers of a FIFO, stored in named shared memory. */
|
||||
class fifo_shmem_t
|
||||
{
|
||||
LONG _nreaders;
|
||||
|
||||
public:
|
||||
int inc_nreaders () { return (int) InterlockedIncrement (&_nreaders); }
|
||||
int dec_nreaders () { return (int) InterlockedDecrement (&_nreaders); }
|
||||
};
|
||||
|
||||
class fhandler_fifo: public fhandler_base
|
||||
@ -1342,6 +1347,9 @@ class fhandler_fifo: public fhandler_base
|
||||
int create_shmem ();
|
||||
int reopen_shmem ();
|
||||
|
||||
int inc_nreaders () { return shmem->inc_nreaders (); }
|
||||
int dec_nreaders () { return shmem->dec_nreaders (); }
|
||||
|
||||
public:
|
||||
fhandler_fifo ();
|
||||
bool hit_eof ();
|
||||
|
Reference in New Issue
Block a user