From 8cef828d8d115c1f98678c13721fee59ca4540b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sat, 18 Aug 2012 22:11:49 +0200 Subject: Make the memory-window conrol structures global Up to now, the idea was that the user would do all the operations for one repository in the same thread. Thus we could have the memory-mapped window information thread-local and avoid any locking. This is not practical in a few environments, such as Apple's GCD which allocates threads arbitrarily or the .NET CLR, where the OS-level thread can change at any moment. Make the control structure global and protect it with a mutex so we don't depend on the thread currently executing the code. --- src/global.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/global.c') diff --git a/src/global.c b/src/global.c index 368c6c664..691f0d4f6 100644 --- a/src/global.c +++ b/src/global.c @@ -9,6 +9,9 @@ #include "git2/threads.h" #include "thread-utils.h" + +git_mutex git__mwindow_mutex; + /** * Handle the global state with TLS * @@ -47,12 +50,14 @@ void git_threads_init(void) _tls_index = TlsAlloc(); _tls_init = 1; + git_mutex_init(&git__mwindow_mutex); } void git_threads_shutdown(void) { TlsFree(_tls_index); _tls_init = 0; + git_mutex_free(&git__mwindow_mutex); } git_global_st *git__global_state(void) -- cgit v1.2.1