mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-19 07:22:14 +08:00
Cygwin: fhandler: move "isclosed" status flag into fhandler_pipe_fifo
The isclosed flag is only used in pipe and FIFO code, so move the flag down into the fhandler_pipe_fifo class. Note that such a flag is not sufficient to avoid evil, like closing an already closing fhandler from another thread. If we ever need this, it has to be implemented threadsafe. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
6baa8484db
commit
c7eb1a1f52
@ -1579,7 +1579,6 @@ fhandler_base::fhandler_base () :
|
|||||||
ra.raixget = 0;
|
ra.raixget = 0;
|
||||||
ra.raixput = 0;
|
ra.raixput = 0;
|
||||||
ra.rabuflen = 0;
|
ra.rabuflen = 0;
|
||||||
isclosed (false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Normal I/O destructor */
|
/* Normal I/O destructor */
|
||||||
|
@ -1524,6 +1524,7 @@ fhandler_fifo::cancel_reader_thread ()
|
|||||||
int
|
int
|
||||||
fhandler_fifo::close ()
|
fhandler_fifo::close ()
|
||||||
{
|
{
|
||||||
|
isclosed (true);
|
||||||
if (select_sem)
|
if (select_sem)
|
||||||
{
|
{
|
||||||
release_select_sem ("close");
|
release_select_sem ("close");
|
||||||
|
@ -31,7 +31,10 @@ STATUS_PIPE_EMPTY simply means there's no data to be read. */
|
|||||||
|| _s == STATUS_PIPE_EMPTY; })
|
|| _s == STATUS_PIPE_EMPTY; })
|
||||||
|
|
||||||
fhandler_pipe_fifo::fhandler_pipe_fifo ()
|
fhandler_pipe_fifo::fhandler_pipe_fifo ()
|
||||||
: fhandler_base (), pipe_buf_size (DEFAULT_PIPEBUFSIZE), pipe_mtx (NULL)
|
: fhandler_base (),
|
||||||
|
status (),
|
||||||
|
pipe_buf_size (DEFAULT_PIPEBUFSIZE),
|
||||||
|
pipe_mtx (NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -758,6 +761,7 @@ fhandler_pipe::dup (fhandler_base *child, int flags)
|
|||||||
int
|
int
|
||||||
fhandler_pipe::close ()
|
fhandler_pipe::close ()
|
||||||
{
|
{
|
||||||
|
isclosed (true);
|
||||||
if (select_sem)
|
if (select_sem)
|
||||||
{
|
{
|
||||||
release_select_sem ("close");
|
release_select_sem ("close");
|
||||||
|
@ -179,14 +179,13 @@ class fhandler_base
|
|||||||
read or write access */
|
read or write access */
|
||||||
unsigned close_on_exec : 1; /* close-on-exec */
|
unsigned close_on_exec : 1; /* close-on-exec */
|
||||||
unsigned need_fork_fixup : 1; /* Set if need to fixup after fork. */
|
unsigned need_fork_fixup : 1; /* Set if need to fixup after fork. */
|
||||||
unsigned isclosed : 1; /* Set when fhandler is closed. */
|
|
||||||
unsigned mandatory_locking : 1; /* Windows mandatory locking */
|
unsigned mandatory_locking : 1; /* Windows mandatory locking */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
status_flags () :
|
status_flags () :
|
||||||
rbinary (0), rbinset (0), wbinary (0), wbinset (0), nohandle (0),
|
rbinary (0), rbinset (0), wbinary (0), wbinset (0), nohandle (0),
|
||||||
did_lseek (0), query_open (no_query), close_on_exec (0),
|
did_lseek (0), query_open (no_query), close_on_exec (0),
|
||||||
need_fork_fixup (0), isclosed (0), mandatory_locking (0)
|
need_fork_fixup (0), mandatory_locking (0)
|
||||||
{}
|
{}
|
||||||
} status, open_status;
|
} status, open_status;
|
||||||
|
|
||||||
@ -290,7 +289,6 @@ class fhandler_base
|
|||||||
IMPLEMENT_STATUS_FLAG (query_state, query_open)
|
IMPLEMENT_STATUS_FLAG (query_state, query_open)
|
||||||
IMPLEMENT_STATUS_FLAG (bool, close_on_exec)
|
IMPLEMENT_STATUS_FLAG (bool, close_on_exec)
|
||||||
IMPLEMENT_STATUS_FLAG (bool, need_fork_fixup)
|
IMPLEMENT_STATUS_FLAG (bool, need_fork_fixup)
|
||||||
IMPLEMENT_STATUS_FLAG (bool, isclosed)
|
|
||||||
IMPLEMENT_STATUS_FLAG (bool, mandatory_locking)
|
IMPLEMENT_STATUS_FLAG (bool, mandatory_locking)
|
||||||
|
|
||||||
int get_default_fmode (int flags);
|
int get_default_fmode (int flags);
|
||||||
@ -1195,11 +1193,20 @@ class fhandler_socket_unix : public fhandler_socket
|
|||||||
/* A parent of fhandler_pipe and fhandler_fifo. */
|
/* A parent of fhandler_pipe and fhandler_fifo. */
|
||||||
class fhandler_pipe_fifo: public fhandler_base
|
class fhandler_pipe_fifo: public fhandler_base
|
||||||
{
|
{
|
||||||
|
struct status_flags
|
||||||
|
{
|
||||||
|
unsigned isclosed : 1; /* Set when pipe/FIFO fhandler is closed. */
|
||||||
|
public:
|
||||||
|
status_flags () : isclosed (0) {}
|
||||||
|
} status;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
size_t pipe_buf_size;
|
size_t pipe_buf_size;
|
||||||
HANDLE pipe_mtx; /* Used only in the pipe case */
|
HANDLE pipe_mtx; /* Used only in the pipe case */
|
||||||
virtual void release_select_sem (const char *) {};
|
virtual void release_select_sem (const char *) {};
|
||||||
|
|
||||||
|
IMPLEMENT_STATUS_FLAG (bool, isclosed)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
fhandler_pipe_fifo ();
|
fhandler_pipe_fifo ();
|
||||||
|
|
||||||
|
@ -333,7 +333,6 @@ mq_close (mqd_t mqd)
|
|||||||
if (mq_notify (mqd, NULL)) /* unregister calling process */
|
if (mq_notify (mqd, NULL)) /* unregister calling process */
|
||||||
__leave;
|
__leave;
|
||||||
|
|
||||||
fd->isclosed (true);
|
|
||||||
fd->close ();
|
fd->close ();
|
||||||
fd.release ();
|
fd.release ();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1692,7 +1692,6 @@ close (int fd)
|
|||||||
res = -1;
|
res = -1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cfd->isclosed (true);
|
|
||||||
res = cfd->close_with_arch ();
|
res = cfd->close_with_arch ();
|
||||||
cfd.release ();
|
cfd.release ();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user