* cygthread.cc (cygthread::terminate_thread): Only try to free
thread stack on systems not freeing it by themselves. * wincap.h (wincaps::terminate_thread_frees_stack): New element. * wincap.cc: Implement above element throughout.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/* cygthread.cc
|
||||
|
||||
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009,
|
||||
2010, 2011, 2012 Red Hat, Inc.
|
||||
2010, 2011, 2012, 2013 Red Hat, Inc.
|
||||
|
||||
This software is a copyrighted work licensed under the terms of the
|
||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||
@@ -313,15 +313,18 @@ cygthread::terminate_thread ()
|
||||
if (ev && !(terminated = !IsEventSignalled (ev)))
|
||||
ResetEvent (ev);
|
||||
|
||||
MEMORY_BASIC_INFORMATION m;
|
||||
memset (&m, 0, sizeof (m));
|
||||
VirtualQuery (stack_ptr, &m, sizeof m);
|
||||
if (!wincap.terminate_thread_frees_stack ())
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION m;
|
||||
memset (&m, 0, sizeof (m));
|
||||
VirtualQuery (stack_ptr, &m, sizeof m);
|
||||
|
||||
if (!m.RegionSize)
|
||||
system_printf ("m.RegionSize 0? stack_ptr %p", stack_ptr);
|
||||
else if (!VirtualFree (m.AllocationBase, 0, MEM_RELEASE))
|
||||
debug_printf ("VirtualFree of allocation base %p<%p> failed, %E",
|
||||
stack_ptr, m.AllocationBase);
|
||||
if (!m.RegionSize)
|
||||
system_printf ("m.RegionSize 0? stack_ptr %p", stack_ptr);
|
||||
else if (!VirtualFree (m.AllocationBase, 0, MEM_RELEASE))
|
||||
debug_printf ("VirtualFree of allocation base %p<%p> failed, %E",
|
||||
stack_ptr, m.AllocationBase);
|
||||
}
|
||||
|
||||
if (is_freerange)
|
||||
free (this);
|
||||
|
Reference in New Issue
Block a user