diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 4 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 16 |
2 files changed, 11 insertions, 9 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 832b39f..4da0b41 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,9 @@ 2003-12-06 Christopher Faylor <cgf@redhat.com> + * exceptions.cc (_threadinfo::remove): Avoid a linked list walk. + +2003-12-06 Christopher Faylor <cgf@redhat.com> + * cygtls.h (_threadinfo::find_tls): New function. * exceptions.cc (_threadinfo::find_tls): Rename from find_tls. Use critical section to protect access to linked list. diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index ea2c7e6..feb3632 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -188,17 +188,15 @@ _threadinfo::init_thread (void *) void _threadinfo::remove () { - _threadinfo *t; EnterCriticalSection (&protect_linked_list); - for (t = _last_thread; t && t != this; t = t->prev) - continue; - if (t) + if (prev) { - t->prev->next = t->next; - if (t->next) - t->next->prev = t->prev; - if (t == _last_thread) - _last_thread = t->prev; + prev->next = next; + if (next) + next->prev = prev; + if (this == _last_thread) + _last_thread = prev; + prev = next = NULL; } LeaveCriticalSection (&protect_linked_list); } |