* thread.h (pthread::init_mainthread): Remove parameter forked.
(pthread::set_tls_self_pointer): New static function. * thread.cc (MTinterface::fixup_after_fork): Change call to pthread::init_mainthread. (pthread::init_mainthread): Remove parameter forked. Simplify thread self pointer handling. (pthread::self): Set thread self pointer to null_pthread if thread has not been initialized. (pthread::set_tls_self_pointer): New static function.
This commit is contained in:
parent
60210cc795
commit
56a188d1f3
|
@ -1,3 +1,15 @@
|
||||||
|
2004-04-09 Thomas Pfaff <tpfaff@gmx.net>
|
||||||
|
|
||||||
|
* thread.h (pthread::init_mainthread): Remove parameter forked.
|
||||||
|
(pthread::set_tls_self_pointer): New static function.
|
||||||
|
* thread.cc (MTinterface::fixup_after_fork): Change call to
|
||||||
|
pthread::init_mainthread.
|
||||||
|
(pthread::init_mainthread): Remove parameter forked. Simplify thread
|
||||||
|
self pointer handling.
|
||||||
|
(pthread::self): Set thread self pointer to null_pthread if thread has
|
||||||
|
not been initialized.
|
||||||
|
(pthread::set_tls_self_pointer): New static function.
|
||||||
|
|
||||||
2004-04-05 Pierre Humblet <pierre.humblet@ieee.org>
|
2004-04-05 Pierre Humblet <pierre.humblet@ieee.org>
|
||||||
|
|
||||||
* path.cc (path_conv::check): Optimize symlink replacements.
|
* path.cc (path_conv::check): Optimize symlink replacements.
|
||||||
|
|
|
@ -153,7 +153,7 @@ MTinterface::fixup_after_fork (void)
|
||||||
pthread_key::fixup_after_fork ();
|
pthread_key::fixup_after_fork ();
|
||||||
|
|
||||||
threadcount = 0;
|
threadcount = 0;
|
||||||
pthread::init_mainthread (true);
|
pthread::init_mainthread ();
|
||||||
|
|
||||||
pthread::fixup_after_fork ();
|
pthread::fixup_after_fork ();
|
||||||
pthread_mutex::fixup_after_fork ();
|
pthread_mutex::fixup_after_fork ();
|
||||||
|
@ -166,23 +166,17 @@ MTinterface::fixup_after_fork (void)
|
||||||
|
|
||||||
/* static methods */
|
/* static methods */
|
||||||
void
|
void
|
||||||
pthread::init_mainthread (const bool forked)
|
pthread::init_mainthread ()
|
||||||
{
|
{
|
||||||
pthread *thread = get_tls_self_pointer ();
|
pthread *thread = get_tls_self_pointer ();
|
||||||
if (!thread)
|
if (!thread)
|
||||||
{
|
|
||||||
if (forked)
|
|
||||||
thread = pthread_null::get_null_pthread ();
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
thread = new pthread ();
|
thread = new pthread ();
|
||||||
if (!thread)
|
if (!thread)
|
||||||
api_fatal ("failed to create mainthread object");
|
api_fatal ("failed to create mainthread object");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
thread->cygtls = &_my_tls;
|
set_tls_self_pointer (thread);
|
||||||
_my_tls.tid = thread;
|
|
||||||
thread->thread_id = GetCurrentThreadId ();
|
thread->thread_id = GetCurrentThreadId ();
|
||||||
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
|
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
|
||||||
GetCurrentProcess (), &thread->win32_obj_id,
|
GetCurrentProcess (), &thread->win32_obj_id,
|
||||||
|
@ -198,9 +192,12 @@ pthread *
|
||||||
pthread::self ()
|
pthread::self ()
|
||||||
{
|
{
|
||||||
pthread *thread = get_tls_self_pointer ();
|
pthread *thread = get_tls_self_pointer ();
|
||||||
if (thread)
|
if (!thread)
|
||||||
|
{
|
||||||
|
thread = pthread_null::get_null_pthread ();
|
||||||
|
set_tls_self_pointer (thread);
|
||||||
|
}
|
||||||
return thread;
|
return thread;
|
||||||
return pthread_null::get_null_pthread ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread *
|
pthread *
|
||||||
|
@ -209,6 +206,13 @@ pthread::get_tls_self_pointer ()
|
||||||
return _my_tls.tid;
|
return _my_tls.tid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pthread::set_tls_self_pointer (pthread *thread)
|
||||||
|
{
|
||||||
|
thread->cygtls = &_my_tls;
|
||||||
|
_my_tls.tid = thread;
|
||||||
|
}
|
||||||
|
|
||||||
List<pthread> pthread::threads;
|
List<pthread> pthread::threads;
|
||||||
|
|
||||||
/* member methods */
|
/* member methods */
|
||||||
|
|
|
@ -373,7 +373,7 @@ public:
|
||||||
pthread ();
|
pthread ();
|
||||||
virtual ~pthread ();
|
virtual ~pthread ();
|
||||||
|
|
||||||
static void init_mainthread (const bool forked = false);
|
static void init_mainthread ();
|
||||||
static bool is_good_object(pthread_t const *);
|
static bool is_good_object(pthread_t const *);
|
||||||
static void atforkprepare();
|
static void atforkprepare();
|
||||||
static void atforkparent();
|
static void atforkparent();
|
||||||
|
@ -447,9 +447,9 @@ private:
|
||||||
void pop_all_cleanup_handlers (void);
|
void pop_all_cleanup_handlers (void);
|
||||||
void precreate (pthread_attr *);
|
void precreate (pthread_attr *);
|
||||||
void postcreate ();
|
void postcreate ();
|
||||||
void set_tls_self_pointer ();
|
|
||||||
bool create_cancel_event ();
|
bool create_cancel_event ();
|
||||||
static pthread *get_tls_self_pointer ();
|
static pthread *get_tls_self_pointer ();
|
||||||
|
static void set_tls_self_pointer (pthread *);
|
||||||
void cancel_self ();
|
void cancel_self ();
|
||||||
DWORD get_thread_id ();
|
DWORD get_thread_id ();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue