summaryrefslogtreecommitdiff
path: root/src/global.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-04-15 00:09:03 -0700
committerVicent Marti <tanoku@gmail.com>2013-04-22 16:52:07 +0200
commit536078688549ac3d50483eecdec5a8169d921927 (patch)
tree3ceb9965aba3f946b89bbbd99a8071707351d50f /src/global.c
parent116bbdf0446cd5335b73e691c3352f368eac9b8f (diff)
downloadlibgit2-536078688549ac3d50483eecdec5a8169d921927.tar.gz
Further threading fixes
This builds on the earlier thread safety work to make it so that setting the odb, index, refdb, or config for a repository is done in a threadsafe manner with minimized locking time. This is done by adding a lock to the repository object and using it to guard the assignment of the above listed pointers. The lock is only held to assign the pointer value. This also contains some minor fixes to the other work with pack files to reduce the time that locks are being held to and fix an apparently memory leak.
Diffstat (limited to 'src/global.c')
-rw-r--r--src/global.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/global.c b/src/global.c
index b7fd8e257..a0571d127 100644
--- a/src/global.c
+++ b/src/global.c
@@ -135,6 +135,12 @@ int git_threads_init(void)
void git_threads_shutdown(void)
{
+ if (_tls_init) {
+ void *ptr = pthread_getspecific(_tls_key);
+ pthread_setspecific(_tls_key, NULL);
+ git__free(ptr);
+ }
+
pthread_key_delete(_tls_key);
_tls_init = 0;
git_mutex_free(&git__mwindow_mutex);