Cygwin: cygthread: set thread name before calling thread func

When reusing a cygthread, the stub method fails to set the thread name
to the new name.  The name is only set when actually creating the
thread.  Fix that by moving the SetThreadName call right in front of the
thread function call.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2019-01-23 21:39:19 +01:00
parent b644774b8f
commit b79b0c2bae
2 changed files with 4 additions and 2 deletions

View File

@ -87,6 +87,7 @@ cygthread::stub (VOID *arg)
#endif
else
{
SetThreadName (info->id, info->__name);
info->callfunc (false);
HANDLE notify = info->notify_detached;
@ -128,6 +129,7 @@ cygthread::simplestub (VOID *arg)
_my_tls._ctinfo = info;
info->stack_ptr = &arg;
HANDLE notify = info->notify_detached;
SetThreadName (info->id, info->__name);
info->callfunc (true);
if (notify)
SetEvent (notify);
@ -213,8 +215,6 @@ cygthread::create ()
this, 0, &id);
if (!htobe)
api_fatal ("CreateThread failed for %s - %p<%y>, %E", __name, h, id);
else
SetThreadName (GetThreadId (htobe), __name);
thread_printf ("created name '%s', thread %p, id %y", __name, h, id);
#ifdef DEBUGGING
terminated = false;

View File

@ -77,3 +77,5 @@ Bug Fixes
- Fix WEOF handling in wctype functions.
Addresses: https://cygwin.com/ml/cygwin/2018-12/msg00173.html
- Fix thread names in GDB when cygthreads get reused.