aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/debug.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/debug.cc')
-rw-r--r--winsup/cygwin/debug.cc27
1 files changed, 20 insertions, 7 deletions
diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc
index bd58e47..551a12d 100644
--- a/winsup/cygwin/debug.cc
+++ b/winsup/cygwin/debug.cc
@@ -275,15 +275,11 @@ out:
unlock_debug ();
}
-/* Close a known handle. Complain if !force and closing a known handle or
- if the name of the handle being closed does not match the registered name. */
-BOOL __stdcall
-close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
+bool __stdcall
+debug_mark_closed (const char *func, int ln, HANDLE h, const char *name, BOOL force)
{
- BOOL ret;
handle_list *hl;
lock_debug ();
-
if ((hl = find_handle (h)) && !force)
{
hl = hl->next;
@@ -301,7 +297,7 @@ close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
hln->func, hln->ln, hln->name, hln->h);
system_printf (" by %s:%d(%s<%p>)", func, ln, name, h);
}
- ret = CloseHandle (h);
+
if (hl)
{
handle_list *hnuke = hl->next;
@@ -313,6 +309,23 @@ close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
}
unlock_debug ();
+ return TRUE;
+}
+
+/* Close a known handle. Complain if !force and closing a known handle or
+ if the name of the handle being closed does not match the registered name. */
+BOOL __stdcall
+close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
+{
+ BOOL ret;
+ lock_debug ();
+
+ if (!debug_mark_closed (func, ln, h, name, force))
+ return FALSE;
+
+ ret = CloseHandle (h);
+
+ unlock_debug ();
#if 0 /* Uncomment to see CloseHandle failures */
if (!ret)
small_printf ("CloseHandle(%s) failed %s:%d\n", name, func, ln);