Cygwin: FIFO: add shared memory
Even though we currently allow a FIFO to be opened for reading only once, we can still have more than one reader open because of dup and fork. Add a named shared memory section accessible to all readers of a given FIFO. In future commits we will add information needed by all readers to this section Add a class fifo_shmem_t that lets us access this information. Add a method create_shmem that is called when a reader opens, and add a method reopen_shmem that is called by dup, fork, and exec. (Each new reader needs its own view of the shared memory.)
This commit is contained in:
@ -1300,6 +1300,11 @@ struct fifo_client_handler
|
||||
int pipe_state ();
|
||||
};
|
||||
|
||||
/* Info needed by all readers of a FIFO, stored in named shared memory. */
|
||||
class fifo_shmem_t
|
||||
{
|
||||
};
|
||||
|
||||
class fhandler_fifo: public fhandler_base
|
||||
{
|
||||
/* Handles to named events shared by all fhandlers for a given FIFO. */
|
||||
@ -1319,6 +1324,10 @@ class fhandler_fifo: public fhandler_base
|
||||
af_unix_spinlock_t _fifo_client_lock;
|
||||
bool reader, writer, duplexer;
|
||||
size_t max_atomic_write;
|
||||
|
||||
HANDLE shmem_handle;
|
||||
fifo_shmem_t *shmem;
|
||||
|
||||
bool __reg2 wait (HANDLE);
|
||||
static NTSTATUS npfs_handle (HANDLE &);
|
||||
HANDLE create_pipe_instance (bool);
|
||||
@ -1330,6 +1339,9 @@ class fhandler_fifo: public fhandler_base
|
||||
void record_connection (fifo_client_handler&,
|
||||
fifo_client_connect_state = fc_connected);
|
||||
|
||||
int create_shmem ();
|
||||
int reopen_shmem ();
|
||||
|
||||
public:
|
||||
fhandler_fifo ();
|
||||
bool hit_eof ();
|
||||
@ -1341,6 +1353,7 @@ public:
|
||||
DWORD fifo_reader_thread_func ();
|
||||
void fifo_client_lock () { _fifo_client_lock.lock (); }
|
||||
void fifo_client_unlock () { _fifo_client_lock.unlock (); }
|
||||
|
||||
int open (int, mode_t);
|
||||
off_t lseek (off_t offset, int whence);
|
||||
int close ();
|
||||
|
Reference in New Issue
Block a user