Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-07-09 08:37:13 +0400
committerChristopher Faylor <me@cgf.cx>2002-07-09 08:37:13 +0400
commit1f5ff38778862dfbf8b878f9c1dbc89b6764ee65 (patch)
treea5df9895ddc8880f0b2cdda27bfc60a4d156c552 /winsup/cygwin/debug.cc
parentf6b5a684289142a09efeb86edf353913a51b2b27 (diff)
* debug.cc: Avoid explicit zeroing of globals.
(lock_debug): Make locker a static member. Avoid unlocking when already unlocked (from Conrad Scott). (debug_init): Initialize lock_debug::locker here. * fork.cc (fork_child): Fix up fdtab earlier to avoid some (but not all) confusion with close-on-exec craziness.
Diffstat (limited to 'winsup/cygwin/debug.cc')
-rw-r--r--winsup/cygwin/debug.cc35
1 files changed, 27 insertions, 8 deletions
diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc
index a530c5c34..dc786ff69 100644
--- a/winsup/cygwin/debug.cc
+++ b/winsup/cygwin/debug.cc
@@ -176,27 +176,45 @@ typedef struct _h
struct _h *next;
} handle_list;
-static NO_COPY handle_list starth = {0, NULL, NULL, NULL, 0, 0, NULL};
-static NO_COPY handle_list *endh = NULL;
+static NO_COPY handle_list starth;
+static NO_COPY handle_list *endh;
-static handle_list NO_COPY freeh[1000] = {{0, NULL, NULL, NULL, 0, 0, NULL}};
+static NO_COPY handle_list freeh[1000];
#define NFREEH (sizeof (freeh) / sizeof (freeh[0]))
-static muto NO_COPY *debug_lock = NULL;
+void debug_init ();
-struct lock_debug
+class lock_debug
{
- lock_debug () {if (debug_lock) debug_lock->acquire (INFINITE);}
- void unlock () {if (debug_lock) debug_lock->release ();}
+ static muto *locker;
+ bool acquired;
+ public:
+ lock_debug () : acquired (0)
+ {
+ if (locker)
+ acquired = !!locker->acquire (INFINITE);
+ }
+ void unlock ()
+ {
+ if (locker && acquired)
+ {
+ locker->release ();
+ acquired = false;
+ }
+ }
~lock_debug () {unlock ();}
+ friend void debug_init ();
};
+muto NO_COPY *lock_debug::locker = NULL;
+
static bool __stdcall mark_closed (const char *, int, HANDLE, const char *, BOOL);
void
debug_init ()
{
- new_muto (debug_lock);
+ muto *debug_lock_muto;
+ lock_debug::locker = new_muto (debug_lock_muto);
}
/* Find a registered handle in the linked list of handles. */
@@ -296,6 +314,7 @@ delete_handle (handle_list *hl)
void
debug_fixup_after_fork ()
{
+ /* No lock needed at this point */
handle_list *hl;
for (hl = &starth; hl->next != NULL; hl = hl->next)
if (hl->next->clexec_pid)