diff options
author | Kotresh HR <khiremat@redhat.com> | 2015-06-17 14:39:26 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2015-06-19 00:12:29 -0700 |
commit | d37920661fa36aa1c77de20351d79f7378222e80 (patch) | |
tree | 2144eaec5f21e6e98ad8cfebf64bc527abbaf29a /xlators/features/changelog | |
parent | 84479bfa28f91c993b4e4a1f0f259a3ae1576791 (diff) |
libgfchangelog: Fix crash in gf_changelog_process
Problem:
Crash observed in gf_changelog_process and
gf_changelog_callback_invoker.
Cause:
Assignments to arguments passed to thread is done
post thread creation. If the thread created gets
scheduled before the assignment and access these
variables, it would crash with segmentation fault.
Solution:
Assignments to arguments are done prior to the thread
creation.
BUG: 1233044
Change-Id: I520599ab43026d25f4064ce71bd5a8b8e0d4b90a
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/11273
Reviewed-on: http://review.gluster.org/11308
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators/features/changelog')
-rw-r--r-- | xlators/features/changelog/lib/src/gf-changelog-journal-handler.c | 9 | ||||
-rw-r--r-- | xlators/features/changelog/lib/src/gf-changelog.c | 13 |
2 files changed, 14 insertions, 8 deletions
diff --git a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c index 2975b06757f..f07d341ddef 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c +++ b/xlators/features/changelog/lib/src/gf-changelog-journal-handler.c @@ -790,13 +790,16 @@ gf_changelog_init_processor (gf_changelog_journal_t *jnl) goto cleanup_mutex; INIT_LIST_HEAD (&jnl_proc->entries); + jnl_proc->waiting = _gf_false; + jnl->jnl_proc = jnl_proc; + ret = pthread_create (&jnl_proc->processor, NULL, gf_changelog_process, jnl); - if (ret != 0) + if (ret != 0) { + jnl->jnl_proc = NULL; goto cleanup_cond; - jnl_proc->waiting = _gf_false; + } - jnl->jnl_proc = jnl_proc; return 0; cleanup_cond: diff --git a/xlators/features/changelog/lib/src/gf-changelog.c b/xlators/features/changelog/lib/src/gf-changelog.c index 82abc662632..874ffd0d13b 100644 --- a/xlators/features/changelog/lib/src/gf-changelog.c +++ b/xlators/features/changelog/lib/src/gf-changelog.c @@ -292,11 +292,6 @@ gf_init_event (gf_changelog_t *entry) ev->next_seq = 0; /* bootstrap sequencing */ - ret = gf_thread_create (&ev->invoker, NULL, - gf_changelog_callback_invoker, ev); - if (ret != 0) - goto cleanup_cond; - if (GF_NEED_ORDERED_EVENTS (entry)) { entry->pickevent = pick_event_ordered; entry->queueevent = queue_ordered_event; @@ -305,6 +300,14 @@ gf_init_event (gf_changelog_t *entry) entry->queueevent = queue_unordered_event; } + ret = gf_thread_create (&ev->invoker, NULL, + gf_changelog_callback_invoker, ev); + if (ret != 0) { + entry->pickevent = NULL; + entry->queueevent = NULL; + goto cleanup_cond; + } + return 0; cleanup_cond: |