aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-06-16 16:21:06 -0700
committerJunio C Hamano <gitster@pobox.com>2010-06-16 16:21:06 -0700
commit5c1eba5e312838774afe44bb52885f3cd7e4ac7a (patch)
treedccf68a10a7a8666720202bcc9ece2ef3138a2b1 /builtin
parent419ff2c575b96555dedac8c736025acfca9f982f (diff)
parent937491944292fa3303b565b9bd8914c6b644ab13 (diff)
downloadgit-5c1eba5e312838774afe44bb52885f3cd7e4ac7a.tar.gz
git-5c1eba5e312838774afe44bb52885f3cd7e4ac7a.tar.xz
Merge branch 'np/malloc-threading' into maint
* np/malloc-threading: Thread-safe xmalloc and xrealloc needs a recursive mutex Make xmalloc and xrealloc thread-safe
Diffstat (limited to 'builtin')
-rw-r--r--builtin/grep.c2
-rw-r--r--builtin/pack-objects.c13
2 files changed, 12 insertions, 3 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 8e928e217..b194ea3ce 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -17,8 +17,8 @@
#include "dir.h"
#ifndef NO_PTHREADS
-#include "thread-utils.h"
#include <pthread.h>
+#include "thread-utils.h"
#endif
static char const * const grep_usage[] = {
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 97802585e..214d7ef2b 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -18,8 +18,8 @@
#include "refs.h"
#ifndef NO_PTHREADS
-#include "thread-utils.h"
#include <pthread.h>
+#include "thread-utils.h"
#endif
static const char pack_usage[] =
@@ -1522,6 +1522,13 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
#ifndef NO_PTHREADS
+static void try_to_free_from_threads(size_t size)
+{
+ read_lock();
+ release_pack_memory(size, -1);
+ read_unlock();
+}
+
/*
* The main thread waits on the condition that (at least) one of the workers
* has stopped working (which is indicated in the .working member of
@@ -1552,14 +1559,16 @@ static pthread_cond_t progress_cond;
*/
static void init_threaded_search(void)
{
- pthread_mutex_init(&read_mutex, NULL);
+ init_recursive_mutex(&read_mutex);
pthread_mutex_init(&cache_mutex, NULL);
pthread_mutex_init(&progress_mutex, NULL);
pthread_cond_init(&progress_cond, NULL);
+ set_try_to_free_routine(try_to_free_from_threads);
}
static void cleanup_threaded_search(void)
{
+ set_try_to_free_routine(NULL);
pthread_cond_destroy(&progress_cond);
pthread_mutex_destroy(&read_mutex);
pthread_mutex_destroy(&cache_mutex);