File tree Expand file tree Collapse file tree 5 files changed +15
-18
lines changed
Expand file tree Collapse file tree 5 files changed +15
-18
lines changed Original file line number Diff line number Diff line change 99
1010#include "global.h"
1111#include "strmap.h"
12+ #include "hash.h"
1213#include <ctype.h>
1314#if GIT_WIN32
1415#include "win32/findfile.h"
Original file line number Diff line number Diff line change 1212#include "sysdir.h"
1313#include "filter.h"
1414#include "settings.h"
15+ #include "mwindow.h"
1516#include "merge_driver.h"
1617#include "pool.h"
1718#include "streams/registry.h"
2223#include "transports/ssh.h"
2324#include "win32/w32_stack.h"
2425
25- git_mutex git__mwindow_mutex ;
26-
2726typedef int (* git_global_init_fn )(void );
2827
2928static git_global_init_fn git__init_callbacks [] = {
@@ -147,9 +146,6 @@ static int synchronized_threads_init(void)
147146 if ((_fls_index = FlsAlloc (fls_free )) == FLS_OUT_OF_INDEXES )
148147 return -1 ;
149148
150- if (git_mutex_init (& git__mwindow_mutex ))
151- return -1 ;
152-
153149 error = init_common ();
154150
155151 return error ;
@@ -186,7 +182,6 @@ int git_libgit2_shutdown(void)
186182 shutdown_common ();
187183
188184 FlsFree (_fls_index );
189- git_mutex_free (& git__mwindow_mutex );
190185 }
191186
192187 /* Exit the lock */
@@ -229,11 +224,7 @@ static void cb__free_status(void *st)
229224
230225static void init_once (void )
231226{
232- if ((init_error = git_mutex_init (& git__mwindow_mutex )) != 0 )
233- return ;
234-
235227 pthread_key_create (& _tls_key , & cb__free_status );
236-
237228 init_error = init_common ();
238229}
239230
@@ -276,7 +267,6 @@ int git_libgit2_shutdown(void)
276267 git__free (ptr );
277268
278269 pthread_key_delete (_tls_key );
279- git_mutex_free (& git__mwindow_mutex );
280270 _once_init = new_once ;
281271
282272out :
Original file line number Diff line number Diff line change 99
1010#include "common.h"
1111
12- #include "mwindow.h"
13- #include "hash.h"
14-
1512typedef struct {
1613 git_error * last_error ;
1714 git_error error_t ;
@@ -27,8 +24,6 @@ typedef struct {
2724
2825git_global_st * git__global_state (void );
2926
30- extern git_mutex git__mwindow_mutex ;
31-
3227#define GIT_GLOBAL (git__global_state())
3328
3429typedef void (* git_global_shutdown_fn )(void );
Original file line number Diff line number Diff line change @@ -29,16 +29,21 @@ size_t git_mwindow__window_size = DEFAULT_WINDOW_SIZE;
2929size_t git_mwindow__mapped_limit = DEFAULT_MAPPED_LIMIT ;
3030size_t git_mwindow__file_limit = DEFAULT_FILE_LIMIT ;
3131
32+ /* Mutex to control access */
33+ git_mutex git__mwindow_mutex ;
34+
3235/* Whenever you want to read or modify this, grab git__mwindow_mutex */
3336git_mwindow_ctl git_mwindow__mem_ctl ;
3437
3538/* Global list of mwindow files, to open packs once across repos */
3639git_strmap * git__pack_cache = NULL ;
3740
38- static void git_mwindow_files_free (void )
41+ static void git_mwindow_global_shutdown (void )
3942{
4043 git_strmap * tmp = git__pack_cache ;
4144
45+ git_mutex_free (& git__mwindow_mutex );
46+
4247 git__pack_cache = NULL ;
4348 git_strmap_free (tmp );
4449}
@@ -47,7 +52,11 @@ int git_mwindow_global_init(void)
4752{
4853 assert (!git__pack_cache );
4954
50- git__on_shutdown (git_mwindow_files_free );
55+ git__on_shutdown (git_mwindow_global_shutdown );
56+
57+ if (git_mutex_init (& git__mwindow_mutex ) != 0 )
58+ return -1 ;
59+
5160 return git_strmap_new (& git__pack_cache );
5261}
5362
Original file line number Diff line number Diff line change 1313#include "map.h"
1414#include "vector.h"
1515
16+ extern git_mutex git__mwindow_mutex ;
17+
1618typedef struct git_mwindow {
1719 struct git_mwindow * next ;
1820 git_map window_map ;
You can’t perform that action at this time.
0 commit comments