From ba7d5d914b2c897aef0616f3d95beb4d17bc51a8 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Wed, 17 Jun 2015 14:39:26 +0530 Subject: 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. Change-Id: I6afc8ccedd050cf4b50b967fef8287a0c834177b BUG: 1232666 Signed-off-by: Kotresh HR Reviewed-on: http://review.gluster.org/11273 Tested-by: NetBSD Build System Reviewed-by: Venky Shankar --- .../features/changelog/lib/src/gf-changelog-journal-handler.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'xlators/features/changelog/lib/src/gf-changelog-journal-handler.c') 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: -- cgit