From 883bbc647820b396ff6929ae4d3cda329981a093 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 29 Nov 2002 07:05:26 +0000 Subject: [PATCH] * pinfo.h (winpids::set): Renamed from init. (winpids::init): New declaration. (winpids::cs): Ditto. (winpids::winpids): Use set rather than init. * external.cc (fillout_pinfo): Ditto. * dcrt0.cc (dll_crt0_1): Call winpids::init. * pinfo.cc (winpids::set): Renamed from init. Wrap calls in critical section. (winpids::init): New function. (winpids::cs): Define. --- winsup/cygwin/ChangeLog | 13 +++++++++++++ winsup/cygwin/dcrt0.cc | 2 ++ winsup/cygwin/external.cc | 2 +- winsup/cygwin/pinfo.cc | 12 +++++++++++- winsup/cygwin/pinfo.h | 6 ++++-- winsup/cygwin/syscalls.cc | 2 +- 6 files changed, 32 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e17bb5ba4..e3642bf36 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,16 @@ +2002-11-29 Christopher Faylor + + * pinfo.h (winpids::set): Renamed from init. + (winpids::init): New declaration. + (winpids::cs): Ditto. + (winpids::winpids): Use set rather than init. + * external.cc (fillout_pinfo): Ditto. + * dcrt0.cc (dll_crt0_1): Call winpids::init. + * pinfo.cc (winpids::set): Renamed from init. Wrap calls in critical + section. + (winpids::init): New function. + (winpids::cs): Define. + 2002-11-28 Christopher Faylor * sigproc.cc (sig_dispatch_pending): Remove assertion. diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 6c6acbd37..d42fbfab9 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -569,6 +569,8 @@ dll_crt0_1 () mainthread.init ("mainthread"); // For use in determining if signals // should be blocked. + winpids::init (); + int envc = 0; char **envp = NULL; diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index 85f4032d0..582bb2add 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -43,7 +43,7 @@ fillout_pinfo (pid_t pid, int winpid) static unsigned int i; if (!pids.npids || !nextpid) { - pids.init (winpid); + pids.set (winpid); i = 0; } diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 6feea6444..75b71f22b 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -613,12 +613,22 @@ winpids::enum9x (bool winpid) return nelem; } +NO_COPY CRITICAL_SECTION winpids::cs; + void -winpids::init (bool winpid) +winpids::set (bool winpid) { + EnterCriticalSection (&cs); npids = (this->*enum_processes) (winpid); if (pidlist) pidlist[npids] = 0; + LeaveCriticalSection (&cs); +} + +void +winpids::init () +{ + InitializeCriticalSection (&cs); } DWORD diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index fe36b5a27..829a2c1ba 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -203,17 +203,19 @@ class winpids DWORD enumNT (bool winpid); DWORD enum9x (bool winpid); void add (DWORD& nelem, bool, DWORD pid); + static CRITICAL_SECTION cs; public: DWORD npids; inline void reset () { npids = 0; release (); } - void init (bool winpid); + void set (bool winpid); winpids (int): enum_processes (&winpids::enum_init) { reset (); } winpids (): pidlist (NULL), npidlist (0), pinfolist (NULL), - enum_processes (&winpids::enum_init), npids (0) { init (0); } + enum_processes (&winpids::enum_init), npids (0) { set (0); } inline DWORD& winpid (int i) const {return pidlist[i];} inline _pinfo *operator [] (int i) const {return (_pinfo *) pinfolist[i];} ~winpids (); void release (); + static void init (); }; extern __inline pid_t diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index edfa3ed2f..eff73942a 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -339,7 +339,7 @@ getsid (pid_t pid) extern "C" ssize_t read (int fd, void *ptr, size_t len) { - const struct iovec iov = + const iovec iov = { iov_base: ptr, iov_len: len