* cygheap.cc (init_cygheap::init_tls_list): Accommodate threadlist
having a new type threadlist_t *. Convert commented out code into an #if 0. Create thread mutex. Explain why. (init_cygheap::remove_tls): Drop timeout value. Always wait infinitely for tls_sentry. Return mutex HANDLE of just deleted threadlist entry. (init_cygheap::find_tls): New implementation taking tls pointer as search parameter. Return threadlist_t *. (init_cygheap::find_tls): Return threadlist_t *. Define ix as auto variable. Drop exception handling since crash must be made impossible due to correct synchronization. Return with locked mutex. * cygheap.h (struct threadlist_t): Define. (struct init_cygheap): Convert threadlist to threadlist_t type. (init_cygheap::remove_tls): Align declaration to above change. (init_cygheap::find_tls): Ditto. (init_cygheap::unlock_tls): Define. * cygtls.cc (_cygtls::remove): Unlock and close mutex when finishing. * exceptions.cc (sigpacket::process): Lock _cygtls area of thread before accessing it. * fhandler_termios.cc (fhandler_termios::bg_check): Ditto. * sigproc.cc (sig_send): Ditto. * thread.cc (pthread::exit): Ditto. Add comment. (pthread::cancel): Ditto.
This commit is contained in:
@ -534,6 +534,14 @@ struct mini_cygheap
|
||||
|
||||
#define NBUCKETS 40
|
||||
|
||||
struct threadlist_t
|
||||
{
|
||||
struct _cygtls *thread;
|
||||
HANDLE mutex; /* Used to avoid accessing tls area of
|
||||
deleted thread. See comment in
|
||||
cygheap::remove_tls for a description. */
|
||||
};
|
||||
|
||||
struct init_cygheap: public mini_cygheap
|
||||
{
|
||||
_cmalloc_entry *chain;
|
||||
@ -561,7 +569,7 @@ struct init_cygheap: public mini_cygheap
|
||||
struct sigaction *sigs;
|
||||
|
||||
fhandler_termios *ctty; /* Current tty */
|
||||
struct _cygtls **threadlist;
|
||||
threadlist_t *threadlist;
|
||||
uint32_t sthreads;
|
||||
pid_t pid; /* my pid */
|
||||
struct { /* Equivalent to using LIST_HEAD. */
|
||||
@ -572,8 +580,10 @@ struct init_cygheap: public mini_cygheap
|
||||
void init_installation_root ();
|
||||
void __reg1 init_tls_list ();;
|
||||
void __reg2 add_tls (_cygtls *);
|
||||
void __reg3 remove_tls (_cygtls *, DWORD);
|
||||
_cygtls __reg3 *find_tls (int, bool&);
|
||||
HANDLE __reg3 remove_tls (_cygtls *);
|
||||
threadlist_t __reg2 *find_tls (_cygtls *);
|
||||
threadlist_t __reg3 *find_tls (int, bool&);
|
||||
void unlock_tls (threadlist_t *t) { if (t) ReleaseMutex (t->mutex); }
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user