From 869484c207b3644b8b59b43c86d8bd44c41badc5 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Jun 15 2011 16:06:30 +0000 Subject: sanlock: fix add_lockspace failure the previous patch did not remove the sp struct from spaces_add list --- diff --git a/src/host_id.c b/src/host_id.c index 33ffca4..8f2bfa8 100644 --- a/src/host_id.c +++ b/src/host_id.c @@ -411,10 +411,7 @@ int add_lockspace(struct sanlk_lockspace *ls) rv = pthread_create(&sp->thread, NULL, lockspace_thread, sp); if (rv < 0) { log_erros(sp, "add_lockspace create thread failed"); - pthread_mutex_lock(&spaces_mutex); - list_del(&sp->list); - pthread_mutex_unlock(&spaces_mutex); - goto fail_free; + goto fail_del; } while (1) { @@ -430,7 +427,7 @@ int add_lockspace(struct sanlk_lockspace *ls) /* the thread exits right away if acquire fails */ pthread_join(sp->thread, NULL); rv = result; - goto fail_free; + goto fail_del; } /* once we move sp to spaces list, tokens can begin using it, @@ -440,12 +437,16 @@ int add_lockspace(struct sanlk_lockspace *ls) if (sp->external_remove || external_shutdown) { rv = -1; pthread_mutex_unlock(&spaces_mutex); - goto fail_free; + goto fail_del; } list_move(&sp->list, &spaces); pthread_mutex_unlock(&spaces_mutex); return 0; + fail_del: + pthread_mutex_lock(&spaces_mutex); + list_del(&sp->list); + pthread_mutex_unlock(&spaces_mutex); fail_free: free(sp); return rv;