diff options
author | sueloverso <sue@mongodb.com> | 2017-04-07 00:17:40 -0400 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2017-04-07 14:17:40 +1000 |
commit | c7b4322b8199a5c0d83f9b44018beb7a35edef09 (patch) | |
tree | aa9c345129518cc9d913ab3ac4c49f150e33519a /src | |
parent | b08187d2e034af66b48203682ecd3737f64545a2 (diff) | |
download | mongo-c7b4322b8199a5c0d83f9b44018beb7a35edef09.tar.gz |
WT-3266 Drop lock while joining threads. (#3375)
Diffstat (limited to 'src')
-rw-r--r-- | src/support/thread_group.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/support/thread_group.c b/src/support/thread_group.c index 422fe38a526..38e3049c264 100644 --- a/src/support/thread_group.c +++ b/src/support/thread_group.c @@ -79,7 +79,6 @@ __thread_group_shrink( if (thread == NULL) continue; - /* Wake threads to ensure they notice the state change */ WT_ASSERT(session, thread->tid != 0); __wt_verbose(session, WT_VERB_THREAD_GROUP, "Stopping utility thread: %p:%" PRIu32, @@ -92,8 +91,27 @@ __thread_group_shrink( */ __wt_cond_signal(session, thread->pause_cond); __wt_cond_signal(session, group->wait_cond); + } + + /* + * We have to perform the join without holding the lock because + * the threads themselves may be waiting on the lock. + */ + __wt_writeunlock(session, &group->lock); + for (current_slot = group->alloc; current_slot > new_count; ) { + thread = group->threads[--current_slot]; + + if (thread == NULL) + continue; WT_TRET(__wt_thread_join(session, thread->tid)); WT_TRET(__wt_cond_destroy(session, &thread->pause_cond)); + } + __wt_writelock(session, &group->lock); + for (current_slot = group->alloc; current_slot > new_count; ) { + thread = group->threads[--current_slot]; + + if (thread == NULL) + continue; WT_ASSERT(session, thread->session != NULL); wt_session = (WT_SESSION *)thread->session; WT_TRET(wt_session->close(wt_session, NULL)); |