aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-10-03 17:23:54 +0000
committerChristopher Faylor <me@cgf.cx>2005-10-03 17:23:54 +0000
commitfa35a1ee5c602b765ca8a2886b2062971f871c47 (patch)
tree74af3f7a62b54047beedf3b65b26a1e3157411e6 /winsup
parent8afb8202d457c054d411988ffd980eea466045a9 (diff)
downloadnewlib-fa35a1ee5c602b765ca8a2886b2062971f871c47.zip
newlib-fa35a1ee5c602b765ca8a2886b2062971f871c47.tar.gz
newlib-fa35a1ee5c602b765ca8a2886b2062971f871c47.tar.bz2
* cygheap.h (class process_lock): New class.
* dtable.h (class dtable): Add class process_lock as a friend. * dcrt0.cc (get_exit_lock): Delete. (do_exit): Use process_lock class instead of get_exit_lock. * exceptions.cc (signal_exit): Ditto. * pinfo.cc (pinfo::exit): Ditto. (_pinfo::commune_process): Set process lock around this whole function. (_pinfo::commune_request): Use process_lock rather than myself.lock. * pinfo.h (pinfo::_lock): Delete. (pinfo::initialize_lock): Delete. (pinfo::lock): Delete. (pinfo::unlock): Delete. * winsup.h (get_exit_lock): Delete declaration.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog17
-rw-r--r--winsup/cygwin/cygheap.h21
-rw-r--r--winsup/cygwin/dcrt0.cc13
-rw-r--r--winsup/cygwin/dtable.h1
-rw-r--r--winsup/cygwin/exceptions.cc6
-rw-r--r--winsup/cygwin/pinfo.cc9
-rw-r--r--winsup/cygwin/pinfo.h4
-rw-r--r--winsup/cygwin/winsup.h1
8 files changed, 49 insertions, 23 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index d5711b3..77b6dec 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,20 @@
+2005-10-03 Christopher Faylor <cgf@timesys.com>
+
+ * cygheap.h (class process_lock): New class.
+ * dtable.h (class dtable): Add class process_lock as a friend.
+ * dcrt0.cc (get_exit_lock): Delete.
+ (do_exit): Use process_lock class instead of get_exit_lock.
+ * exceptions.cc (signal_exit): Ditto.
+ * pinfo.cc (pinfo::exit): Ditto.
+ (_pinfo::commune_process): Set process lock around this whole function.
+ (_pinfo::commune_request): Use process_lock rather than myself.lock.
+ * pinfo.h (pinfo::_lock): Delete.
+ (pinfo::initialize_lock): Delete.
+ (pinfo::lock): Delete.
+ (pinfo::unlock): Delete.
+ * winsup.h (get_exit_lock): Delete declaration.
+
+
2005-10-03 Corinna Vinschen <corinna@vinschen.de>
* uname.cc (uname): Disable use of GetNativeSystemInfo.
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index e5ce58f..059e01d 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -415,6 +415,27 @@ class cygheap_fdenum : public cygheap_fdmanip
}
};
+class process_lock
+{
+ bool skip_unlock;
+public:
+ process_lock (bool exiting = false)
+ {
+ cygheap->fdtab.lock ();
+ skip_unlock = exiting;
+ if (exiting && exit_state < ES_SET_MUTO)
+ {
+ exit_state = ES_SET_MUTO;
+ muto::set_exiting_thread ();
+ }
+ }
+ ~process_lock ()
+ {
+ if (!skip_unlock)
+ cygheap->fdtab.unlock ();
+ }
+};
+
class child_info;
void __stdcall cygheap_fixup_in_child (bool);
extern "C" {
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 48a7b9f..6f82e12 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -1021,7 +1021,7 @@ do_exit (int status)
}
#endif
- get_exit_lock ();
+ process_lock until_exit (true);
if (exit_state < ES_GLOBAL_DTORS)
{
@@ -1138,17 +1138,6 @@ _exit (int n)
do_exit (((DWORD) n & 0xff) << 8);
}
-void
-get_exit_lock ()
-{
- myself.lock ();
- if (exit_state < ES_SET_MUTO)
- {
- exit_state = ES_SET_MUTO;
- muto::set_exiting_thread ();
- }
-}
-
extern "C" void
__api_fatal (const char *fmt, ...)
{
diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h
index 202e288..b71b3f1 100644
--- a/winsup/cygwin/dtable.h
+++ b/winsup/cygwin/dtable.h
@@ -89,6 +89,7 @@ public:
friend class cygheap_fdget;
friend class cygheap_fdnew;
friend class cygheap_fdenum;
+ friend class process_lock;
};
fhandler_base *build_fh_dev (const device&, const char * = NULL);
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 93a3e80..b131523 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -26,6 +26,10 @@ details. */
#include "shared_info.h"
#include "perprocess.h"
#include "security.h"
+#include "path.h"
+#include "fhandler.h"
+#include "dtable.h"
+#include "cygheap.h"
#define CALL_HANDLER_RETRY 20
@@ -1179,7 +1183,7 @@ signal_exit (int rc)
TerminateProcess (hExeced, sigExeced = rc);
}
- get_exit_lock ();
+ process_lock until_exit (true);
if (hExeced || exit_state)
myself.exit (rc);
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index e77a4e6..5df86c7 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -59,7 +59,6 @@ set_myself (HANDLE h)
#endif
strace.hello ();
debug_printf ("myself->dwProcessId %u", myself->dwProcessId);
- myself.initialize_lock ();
if (h)
{
/* here if execed */
@@ -140,7 +139,7 @@ pinfo::zap_cwd ()
void
pinfo::exit (DWORD n)
{
- get_exit_lock ();
+ process_lock until_exit ();
cygthread::terminate ();
if (n != EXITCODE_NOSET)
self->exitcode = EXITCODE_SET | n;/* We're really exiting. Record the UNIX exit code. */
@@ -390,6 +389,8 @@ _pinfo::commune_process (siginfo_t& si)
if (process_sync) // FIXME: this test shouldn't be necessary
ProtectHandle (process_sync);
+ process_lock now (false);
+
switch (si._si_commune._si_code)
{
case PICOM_CMDLINE:
@@ -586,7 +587,7 @@ _pinfo::commune_request (__uint32_t code, ...)
break;
}
- myself.lock ();
+ process_lock now ();
locked = true;
char name_buf[CYG_MAX_PATH];
request_sync = CreateSemaphore (&sec_none_nih, 0, LONG_MAX,
@@ -665,8 +666,6 @@ out:
ReleaseSemaphore (request_sync, 1, &res);
ForceCloseHandle (request_sync);
}
- if (locked)
- myself.unlock ();
if (hp)
CloseHandle (hp);
if (fromthem)
diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h
index 1462e5f..0c7a264 100644
--- a/winsup/cygwin/pinfo.h
+++ b/winsup/cygwin/pinfo.h
@@ -149,7 +149,6 @@ class pinfo
public:
HANDLE rd_proc_pipe;
HANDLE hProcess;
- CRITICAL_SECTION _lock;
bool waiter_ready;
class cygthread *wait_thread;
void init (pid_t, DWORD, HANDLE) __attribute__ ((regparm(3)));
@@ -166,9 +165,6 @@ public:
}
void exit (DWORD n) __attribute__ ((noreturn, regparm(2)));
void maybe_set_exit_code_from_windows () __attribute__ ((regparm(1)));
- void initialize_lock () {InitializeCriticalSection (&_lock);}
- void lock () {EnterCriticalSection (&_lock);}
- void unlock () {LeaveCriticalSection (&_lock);}
_pinfo *operator -> () const {return procinfo;}
int operator == (pinfo *x) const {return x->procinfo == procinfo;}
int operator == (pinfo &x) const {return x.procinfo == procinfo;}
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 004f5b9..d31dd9a 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -203,7 +203,6 @@ enum exit_states
extern exit_states exit_state;
void __stdcall do_exit (int) __attribute__ ((regparm (1), noreturn));
-void __stdcall get_exit_lock ();
/* UID/GID */
void uinfo_init ();