diff options
author | Justin Spahr-Summers <Justin.SpahrSummers@gmail.com> | 2012-12-09 02:31:39 -0800 |
---|---|---|
committer | Justin Spahr-Summers <Justin.SpahrSummers@gmail.com> | 2012-12-09 02:31:39 -0800 |
commit | a35b3864583bd1c98334aa71bb4e4c217ace55aa (patch) | |
tree | 1045996d00b52649b70e929d09114aa606e78842 /src/pack-objects.c | |
parent | c3320aca7640386a2cfc0c785560ff4d36851ef9 (diff) | |
download | libgit2-a35b3864583bd1c98334aa71bb4e4c217ace55aa.tar.gz |
Always check the result of git_mutex_lock
Diffstat (limited to 'src/pack-objects.c')
-rw-r--r-- | src/pack-objects.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/pack-objects.c b/src/pack-objects.c index 44ad3fd98..2eb69764d 100644 --- a/src/pack-objects.c +++ b/src/pack-objects.c @@ -1025,6 +1025,14 @@ static void *threaded_find_deltas(void *arg) git_cond_signal(&me->pb->progress_cond); git_packbuilder__progress_unlock(me->pb); + if (git_mutex_lock(&me->mutex)) { + giterr_set(GITERR_THREAD, "unable to lock packfile condition mutex"); + return NULL; + } + + while (!me->data_ready) + git_cond_wait(&me->cond, &me->mutex); + /* * We must not set ->data_ready before we wait on the * condition because the main thread may have set it to 1 @@ -1033,9 +1041,6 @@ static void *threaded_find_deltas(void *arg) * was initialized to 0 before this thread was spawned * and we reset it to 0 right away. */ - git_mutex_lock(&me->mutex); - while (!me->data_ready) - git_cond_wait(&me->cond, &me->mutex); me->data_ready = 0; git_mutex_unlock(&me->mutex); } @@ -1168,7 +1173,12 @@ static int ll_find_deltas(git_packbuilder *pb, git_pobject **list, target->working = 1; git_packbuilder__progress_unlock(pb); - git_mutex_lock(&target->mutex); + if (git_mutex_lock(&target->mutex)) { + giterr_set(GITERR_THREAD, "unable to lock packfile condition mutex"); + git__free(p); + return -1; + } + target->data_ready = 1; git_cond_signal(&target->cond); git_mutex_unlock(&target->mutex); |